[med-svn] [Git][med-team/ctdopts][upstream] New upstream version 1.4

Andreas Tille gitlab at salsa.debian.org
Thu Oct 1 12:47:14 BST 2020



Andreas Tille pushed to branch upstream at Debian Med / ctdopts


Commits:
c2c11f89 by Andreas Tille at 2020-10-01T13:44:57+02:00
New upstream version 1.4
- - - - -


4 changed files:

- CTDopts/CTDopts.py
- dist/conda/meta.yaml
- example.py
- setup.py


Changes:

=====================================
CTDopts/CTDopts.py
=====================================
@@ -1,6 +1,7 @@
 import argparse
-from collections import OrderedDict, Mapping
 from itertools import chain
+import collections
+import collections.abc
 from xml.etree.ElementTree import Element, SubElement, tostring, parse
 from xml.dom.minidom import parseString
 import warnings
@@ -46,12 +47,27 @@ class _OutFile(str):
     pass
 
 
+class _OutPrefix(str):
+    """Same thing, a dummy class for output-prefix CTD type."""
+    pass
+
+
+class _InPrefix(str):
+    """Same thing, a dummy class for output-prefix CTD type."""
+    pass
+
+
 # module globals for some common operations (python types to CTD-types back and forth)
 TYPE_TO_CTDTYPE = {int: 'int', float: 'double', str: 'string', bool: 'bool',
-                   _InFile: 'input-file', _OutFile: 'output-file'}
-CTDTYPE_TO_TYPE = {'int': int, 'float': float, 'double': float, 'string': str, 'boolean': bool, 'bool': bool,
-                   'input-file': _InFile, 'output-file': _OutFile, int: int, float: float, str: str,
-                   bool: bool, _InFile: _InFile, _OutFile: _OutFile}
+                   _InFile: 'input-file', _OutFile: 'output-file',
+                   _OutPrefix: 'output-prefix', _InPrefix: 'input-prefix'}
+CTDTYPE_TO_TYPE = {'int': int, 'float': float, 'double': float, 'string': str,
+                   'boolean': bool, 'bool': bool,
+                   'input-file': _InFile, 'output-file': _OutFile,
+                   'output-prefix': _OutPrefix, 'input-prefix': _InPrefix,
+                   int: int, float: float, str: str,
+                   bool: bool, _InFile: _InFile, _OutFile: _OutFile,
+                   _OutPrefix: _OutPrefix, _InPrefix: _InPrefix}
 PARAM_DEFAULTS = {'advanced': False, 'required': False, 'restrictions': None, 'description': None,
                   'supported_formats': None, 'tags': None, 'position': None}  # unused. TODO.
 
@@ -115,7 +131,7 @@ def flatten_dict(arg_dict, as_string=False):
         # recursive closure that accesses and modifies result dict and registers nested elements
         # as it encounters them
         for key, value in subgroup.items():
-            if isinstance(value, Mapping):  # collections.Mapping instead of dict for generality
+            if isinstance(value, collections.abc.Mapping):  # collections.Mapping instead of dict for generality
                 flattener(value, level + [key])
             else:
                 result[tuple(level + [key])] = value
@@ -550,7 +566,7 @@ class Parameter(object):
         # XML attributes to be created (depending on whether they are needed or not):
         # name, value, type, description, tags, restrictions, supported_formats
 
-        attribs = OrderedDict()  # LXML keeps the order, ElemenTree doesn't. We use ElementTree though.
+        attribs = collections.OrderedDict()  # LXML keeps the order, ElemenTree doesn't. We use ElementTree though.
         attribs['name'] = self.name
         if not self.is_list:  # we'll deal with list parameters later, now only normal:
             # TODO: once Param_1_6_3.xsd gets fixed, we won't have to set an empty value='' attrib.
@@ -597,7 +613,7 @@ class Parameter(object):
 
 class ParameterGroup(object):
     def __init__(self, name=None, parent=None, node=None, description=None):
-        self.parameters = OrderedDict()
+        self.parameters = collections.OrderedDict()
         self.name = name
         self.parent = parent
         self.description = description
@@ -1091,7 +1107,7 @@ class CTDModel(object):
             'error': standard error or whatever error log the user wants to store
         `cli`: boolean whether or not cli elements should be generated (needed for GenericKNIMENode for example)
         """
-        tool_attribs = OrderedDict()
+        tool_attribs = collections.OrderedDict()
         tool_attribs['version'] = self.version
         tool_attribs['name'] = self.name
         tool_attribs['xmlns:xsi'] = "http://www.w3.org/2001/XMLSchema-instance"


=====================================
dist/conda/meta.yaml
=====================================
@@ -1,13 +1,13 @@
 package:
   name: ctdopts
-  version: "1.2"
+  version: "1.4"
 
 source:
-  git_rev: v1.2
+  git_rev: v1.4
   git_url: https://github.com/WorkflowConversion/CTDopts.git
 
 build:
-  noarch_python: True
+  noarch: python  
 
 requirements:
   build:


=====================================
example.py
=====================================
@@ -45,6 +45,15 @@ model.add(
     description='A list of filenames to feed this dummy tool with'
 )
 
+model.add(
+    'output',
+    required=True,
+    type='output-prefix',  # or 'input-prefix'
+    is_list=False,
+    file_formats=['fastq', 'fastq.gz'],  # filename restrictions
+    description='Output directory'
+)
+
 model.add(
     'this_that',
     type=str,
@@ -194,7 +203,7 @@ print("So how to deal with command line arguments? If we have a model, we can lo
       "Call CTDModel.parse_cl_args() with either a string of the command line call or a list with the split words. "
       "By default, it will assume a '--' prefix before parameter names, but it can be overridden with prefix='-'."
       "Grouped parameters are expected in --group:subgroup:param_x format.")
-cl_args = model.parse_cl_args('--positive_int 44 --subparams:param_2 5.0 5.5 6.0 --input_files a.fastq b.fastq')
+cl_args = model.parse_cl_args('--positive_int 44 --subparams:param_2 5.0 5.5 6.0 --input_files a.fastq b.fastq --output out_dir/')
 pretty_print(cl_args)
 print()
 # # you can get unmatchable command line arguments with get_remaining=True like:


=====================================
setup.py
=====================================
@@ -2,7 +2,7 @@ from distutils.core import setup
 
 setup(
     name='CTDopts',
-    version='1.3',
+    version='1.4',
     packages=['CTDopts'],
     url='https://github.com/genericworkflownodes/CTDopts',
     license='',



View it on GitLab: https://salsa.debian.org/med-team/ctdopts/-/commit/c2c11f894ce0514441c682efdc25dfe3bc08d7d1

-- 
View it on GitLab: https://salsa.debian.org/med-team/ctdopts/-/commit/c2c11f894ce0514441c682efdc25dfe3bc08d7d1
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20201001/9fdf2b01/attachment-0001.html>


More information about the debian-med-commit mailing list