Skip to content

Commit

Permalink
Move parsec to cylc.parsec
Browse files Browse the repository at this point in the history
  • Loading branch information
kinow authored and Bruno P. Kinoshita committed Apr 30, 2019
1 parent 88b59c1 commit 7620ed7
Show file tree
Hide file tree
Showing 114 changed files with 954 additions and 105 deletions.
5 changes: 0 additions & 5 deletions .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,5 @@ exclude_paths:
- 'doc/joss-paper/**'
- 'etc/**'
- 'lib/cylc/tests/**'
- 'lib/isodatetime/**'
- 'lib/jinja2/**'
- 'lib/markupsafe/**'
- 'lib/parsec/tests/**'
- 'licences/**'
- 'tests/**'

4 changes: 2 additions & 2 deletions .travis/shellchecker
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ default () {
# run a strict check on all "functional" scripts
main '.' \
--exclude 'tests/' \
--exclude 'lib/parsec/tests' \
--exclude 'lib/cylc/tests/parsec' \
--exclude 'etc/dev-bin/live-graph-movie.sh' \
-- -e SC1090

# run a lenient check on all test scripts
main 'tests' 'lib/parsec/tests' -- -S error -e SC1090
main 'tests' 'lib/cylc/tests/parsec' -- -S error -e SC1090
}

if [[ $# -gt 0 ]]; then
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-broadcast
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ from cylc.network.client import SuiteRuntimeClient
from cylc.option_parsers import CylcOptionParser as COP
from cylc.print_tree import print_tree
from cylc.task_id import TaskID
from parsec.config import ParsecConfig
from cylc.parsec.config import ParsecConfig


REC_ITEM = re.compile(r'^\[([^\]]*)\](.*)$')
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-edit
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ from subprocess import call
from shutil import copy


from parsec.include import inline, \
from cylc.parsec.include import inline, \
split_file, backup, backups, newfiles, cleanup, modtimes


Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-monitor
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import os
import re
from time import sleep, time

from parsec.OrderedDict import OrderedDict
from cylc.parsec.OrderedDict import OrderedDict

from cylc.exceptions import ClientError
from cylc.option_parsers import CylcOptionParser as COP
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-search
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ from collections import deque
from cylc.option_parsers import CylcOptionParser as COP
from cylc.suite_srv_files_mgr import SuiteSrvFilesManager
from cylc.terminal import cli_function
from parsec.include import inline
from cylc.parsec.include import inline


def section_level(heading):
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ from cylc.option_parsers import CylcOptionParser as COP
from cylc.suite_srv_files_mgr import SuiteSrvFilesManager
from cylc.templatevars import load_template_vars
from cylc.terminal import cli_function
from parsec.fileparse import read_and_proc
from cylc.parsec.fileparse import read_and_proc


def parse_args():
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import os
import sys
from parsec import LOG
from cylc.parsec import LOG


def environ_init():
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/batch_sys_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
JOB_LOG_STATUS)
from cylc.task_outputs import TASK_OUTPUT_SUCCEEDED
from cylc.wallclock import get_current_time_string
from parsec.OrderedDict import OrderedDict
from cylc.parsec.OrderedDict import OrderedDict


class JobPollContext(object):
Expand Down
6 changes: 3 additions & 3 deletions lib/cylc/cfgspec/globalcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import shutil
from tempfile import mkdtemp

from parsec.config import ParsecConfig
from parsec.exceptions import ParsecError
from parsec.upgrade import upgrader
from cylc.parsec.config import ParsecConfig
from cylc.parsec.exceptions import ParsecError
from cylc.parsec.upgrade import upgrader

from cylc import LOG
from cylc.cfgvalidate import (
Expand Down
4 changes: 2 additions & 2 deletions lib/cylc/cfgspec/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

from isodatetime.data import Calendar

from parsec.upgrade import upgrader
from parsec.config import ParsecConfig
from cylc.parsec.upgrade import upgrader
from cylc.parsec.config import ParsecConfig

from cylc.cfgvalidate import (
cylc_config_validate, CylcConfigValidator as VDR, DurationFloat)
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/cfgvalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from isodatetime.data import Calendar, Duration, TimePoint
from isodatetime.dumpers import TimePointDumper
from isodatetime.parsers import DurationParser, TimePointParser
from parsec.validate import ParsecValidator, IllegalValueError
from cylc.parsec.validate import ParsecValidator, IllegalValueError

from cylc.subprocctx import SubFuncContext

Expand Down
4 changes: 2 additions & 2 deletions lib/cylc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

from isodatetime.data import Calendar
from isodatetime.parsers import DurationParser
from parsec.OrderedDict import OrderedDictWithDefaults
from parsec.util import replicate
from cylc.parsec.OrderedDict import OrderedDictWithDefaults
from cylc.parsec.util import replicate

from cylc import LOG
from cylc.c3mro import C3
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/cycling/iso8601.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
SequenceDegenerateError, PointParsingError, IntervalParsingError
)
from cylc.wallclock import get_current_time_string
from parsec.validate import IllegalValueError
from cylc.parsec.validate import IllegalValueError

CYCLER_TYPE_ISO8601 = "iso8601"
CYCLER_TYPE_SORT_KEY_ISO8601 = "b"
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/param_expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def expand(template, params, results, values=None):

from cylc.exceptions import ParamExpandError
from cylc.task_id import TaskID
from parsec.OrderedDict import OrderedDictWithDefaults
from cylc.parsec.OrderedDict import OrderedDictWithDefaults

# To split runtime heading name lists.
REC_NAMES = re.compile(r'(?:[^,<]|<[^>]*>)+')
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions lib/parsec/config.py → lib/cylc/parsec/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import re
from parsec.exceptions import (
from cylc.parsec.exceptions import (
ParsecError, ItemNotFoundError, NotSingleItemError)
from parsec.fileparse import parse
from parsec.util import printcfg
from parsec.validate import parsec_validate
from parsec.OrderedDict import OrderedDictWithDefaults
from parsec.util import itemstr, m_override, replicate, un_many
from cylc.parsec.fileparse import parse
from cylc.parsec.util import printcfg
from cylc.parsec.validate import parsec_validate
from cylc.parsec.OrderedDict import OrderedDictWithDefaults
from cylc.parsec.util import itemstr, m_override, replicate, un_many


class ParsecConfig(object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import em
import os

from parsec.exceptions import EmPyError
from cylc.parsec.exceptions import EmPyError


def empyprocess(flines, dir_, template_vars=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Legal items and validators for the parsec test config file."""

from parsec.validate import ParsecValidator as vdr
from cylc.parsec.validate import ParsecValidator as vdr


SPEC = {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import os
import sys

from cfgspec import SPEC
from parsec.config import ParsecConfig
from cylc.cfgspec.globalcfg import SPEC
from cylc.parsec.config import ParsecConfig
import cylc.flags

# parse:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/parsec/exceptions.py → lib/cylc/parsec/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import os
import textwrap

from parsec.util import itemstr
from cylc.parsec.util import itemstr


TRACEBACK_WRAPPER = textwrap.TextWrapper()
Expand Down
14 changes: 7 additions & 7 deletions lib/parsec/fileparse.py → lib/cylc/parsec/fileparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
import sys
import re

from parsec import LOG
from parsec.exceptions import ParsecError, FileParseError
from parsec.OrderedDict import OrderedDictWithDefaults
from parsec.include import inline
from parsec.util import itemstr
from cylc.parsec import LOG
from cylc.parsec.exceptions import ParsecError, FileParseError
from cylc.parsec.OrderedDict import OrderedDictWithDefaults
from cylc.parsec.include import inline
from cylc.parsec.util import itemstr


# heading/sections can contain commas (namespace name lists) and any
Expand Down Expand Up @@ -246,7 +246,7 @@ def read_and_proc(fpath, template_vars=None, viewcfg=None, asedit=False):
if flines and re.match(r'^#![Ee]m[Pp]y\s*', flines[0]):
LOG.debug('Processing with EmPy')
try:
from parsec.empysupport import empyprocess
from cylc.parsec.empysupport import empyprocess
except (ImportError, ModuleNotFoundError):
raise ParsecError('EmPy Python package must be installed '
'to process file: ' + fpath)
Expand All @@ -257,7 +257,7 @@ def read_and_proc(fpath, template_vars=None, viewcfg=None, asedit=False):
if flines and re.match(r'^#![jJ]inja2\s*', flines[0]):
LOG.debug('Processing with Jinja2')
try:
from parsec.jinja2support import jinja2process
from cylc.parsec.jinja2support import jinja2process
except (ImportError, ModuleNotFoundError):
raise ParsecError('Jinja2 Python package must be installed '
'to process file: ' + fpath)
Expand Down
2 changes: 1 addition & 1 deletion lib/parsec/include.py → lib/cylc/parsec/include.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import sys
from shutil import copy as shcopy

from parsec.exceptions import ParsecError, IncludeFileNotFoundError
from cylc.parsec.exceptions import ParsecError, IncludeFileNotFoundError


done = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
TemplateNotFound,
TemplateSyntaxError)

from parsec import LOG
from parsec.exceptions import Jinja2Error
from cylc.parsec import LOG
from cylc.parsec.exceptions import Jinja2Error


TRACEBACK_LINENO = re.compile(r'(\s+)?File "<template>", line (\d+)')
Expand Down
8 changes: 4 additions & 4 deletions lib/parsec/upgrade.py → lib/cylc/parsec/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

from logging import DEBUG, WARNING

from parsec import LOG
from parsec.exceptions import UpgradeError
from parsec.OrderedDict import OrderedDict
from cylc.parsec import LOG
from cylc.parsec.exceptions import UpgradeError
from cylc.parsec.OrderedDict import OrderedDict


class converter(object):
Expand Down Expand Up @@ -195,7 +195,7 @@ def upgrade(self):

if __name__ == "__main__":
import sys
from parsec.util import printcfg
from cylc.parsec.util import printcfg

cfg = {
'item one': 1,
Expand Down
2 changes: 1 addition & 1 deletion lib/parsec/util.py → lib/cylc/parsec/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from copy import copy
import sys

from parsec.OrderedDict import OrderedDictWithDefaults
from cylc.parsec.OrderedDict import OrderedDictWithDefaults


def intlistjoin(lst):
Expand Down
6 changes: 3 additions & 3 deletions lib/parsec/validate.py → lib/cylc/parsec/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import re
from textwrap import dedent

from parsec.exceptions import (
from cylc.parsec.exceptions import (
ListValueError, IllegalValueError, IllegalItemError)


Expand Down Expand Up @@ -227,7 +227,7 @@ def coerce_spaceless_str_list(cls, value, keys):
>>> ParsecValidator.coerce_spaceless_str_list(
... 'a, b c, d', ['foo']) # doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
parsec.exceptions.ListValueError: \
cylc.parsec.exceptions.ListValueError: \
(type=list) foo = a, b c, d - \
(list item "b c" cannot contain a space character)
Expand All @@ -250,7 +250,7 @@ def coerce_absolute_host_list(cls, value, keys):
... 'foo, bar, 127.0.0.1:8080, baz', ['pub']
... ) # doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
parsec.exceptions.ListValueError: \
cylc.parsec.exceptions.ListValueError: \
(type=list) pub = foo, bar, 127.0.0.1:8080, baz - \
(ambiguous host "127.0.0.1:8080")
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from uuid import uuid4

from isodatetime.parsers import TimePointParser
from parsec.util import printcfg
from cylc.parsec.util import printcfg

from cylc import LOG
from cylc.broadcast_mgr import BroadcastMgr
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/task_events_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import shlex
from time import time

from parsec.config import ItemNotFoundError
from cylc.parsec.config import ItemNotFoundError

from cylc import LOG
from cylc.cfgspec.glbl_cfg import glbl_cfg
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/task_job_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from time import time
import traceback

from parsec.util import pdeepcopy, poverride
from cylc.parsec.util import pdeepcopy, poverride

from cylc import LOG
from cylc.batch_sys_manager import JobPollContext
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import json
from time import time

from parsec.OrderedDict import OrderedDict
from cylc.parsec.OrderedDict import OrderedDict

from cylc import LOG
from cylc.cycling.loader import get_point, standardise_point_string
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import sys

from parsec.exceptions import ParsecError
from cylc.parsec.exceptions import ParsecError

from cylc.cfgspec.glbl_cfg import glbl_cfg
from cylc.exceptions import CylcError
Expand Down
17 changes: 17 additions & 0 deletions lib/cylc/tests/parsec/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3

# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) 2008-2019 NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
sys.path.append(fpath + '/../../..')


from parsec.config import ParsecConfig
from parsec.validate import ParsecValidator as VDR
from cylc.parsec.config import ParsecConfig
from cylc.parsec.validate import ParsecValidator as VDR

SPEC = {'foo': {'bar': {'__MANY__': [VDR.V_STRING]}}}
cfg = ParsecConfig(SPEC)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit 7620ed7

Please sign in to comment.