Пример #1
0
def download(params,
             filefunc,
             statusfunc,
             finfunc,
             errorfunc,
             doneflag,
             cols,
             pathFunc=None,
             paramfunc=None,
             spewflag=Event()):
    if len(params) == 0:
        errorfunc('arguments are -\n' + formatDefinitions(defaults, cols))
        return
    try:
        config, args = parseargs(params, defaults, 0, 1)
        if args:
            if config.get('responsefile', None) == None:
                raise ValueError, 'must have responsefile as arg or parameter, not both'
            if path.isfile(args[0]):
                config['responsefile'] = args[0]
            else:
                config['url'] = args[0]
        if (config['responsefile'] == '') == (config['url'] == ''):
            raise ValueError, 'need responsefile or url'
    except ValueError, e:
        errorfunc('error: ' + str(e) +
                  '\nrun with no args for parameter explanations')
        return
Пример #2
0
 def render_macro(self, req, name, content):
     from trac.web.chrome import add_stylesheet
     from parseargs import parseargs
     add_stylesheet(req, 'tags/css/tractags.css')
     # Translate macro args into python args
     args = []
     kwargs = {}
     try:
         # Set default args from config
         _, config_args = parseargs(self.env.config.get('tags', '%s.args' % name.lower(), ''))
         kwargs.update(config_args)
         if content is not None:
             args, macro_args = parseargs(content)
             kwargs.update(macro_args)
     except Exception, e:
         raise TracError("Invalid arguments '%s' (%s %s)" % (content, e.__class__.__name__, e))
Пример #3
0
def track(args):
    if len(args) == 0:
        print formatDefinitions(defaults, 80)
        return
    try:
        config, files = parseargs(args, defaults, 0, 0)
    except ValueError, e:
        print 'error: ' + str(e)
        print 'run with no arguments for parameter explanations'
        return
Пример #4
0
def track(args):
    if len(args) == 0:
        print formatDefinitions(defaults, 80)
        return
    try:
        config, files = parseargs(args, defaults, 0, 0)
    except ValueError, e:
        print 'error: ' + str(e)
        print 'run with no arguments for parameter explanations'
        return
Пример #5
0
 def render_macro(self, req, name, content):
     from trac.web.chrome import add_stylesheet
     add_stylesheet(req, 'tags/css/tractags.css')
     # Translate macro args into python args
     args = []
     kwargs = {}
     if content is not None:
         try:
             from parseargs import parseargs
             args, kwargs = parseargs(content)
         except Exception, e:
             raise TracError("Invalid arguments '%s' (%s %s)" % (content, e.__class__.__name__, e))
Пример #6
0
 def render_macro(self, req, name, content):
     from trac.web.chrome import add_stylesheet
     add_stylesheet(req, 'tags/css/tractags.css')
     # Translate macro args into python args
     args = []
     kwargs = {}
     if content is not None:
         try:
             from parseargs import parseargs
             args, kwargs = parseargs(content)
         except Exception, e:
             raise TracError("Invalid arguments '%s' (%s %s)" %
                             (content, e.__class__.__name__, e))
Пример #7
0
def download(params, filefunc, statusfunc, finfunc, errorfunc, doneflag, cols, pathFunc = None, paramfunc = None, spewflag = Event()):
    if len(params) == 0:
        errorfunc('arguments are -\n' + formatDefinitions(defaults, cols))
        return
    try:
        config, args = parseargs(params, defaults, 0, 1)
        if args:
            if config.get('responsefile', None) == None:
                raise ValueError, 'must have responsefile as arg or parameter, not both'
            if path.isfile(args[0]):
                config['responsefile'] = args[0]
            else: 
                config['url'] = args[0]
        if (config['responsefile'] == '') == (config['url'] == ''):
            raise ValueError, 'need responsefile or url'
    except ValueError, e:
        errorfunc('error: ' + str(e) + '\nrun with no args for parameter explanations')
        return
Пример #8
0
def parse_params(params, presets={}):
    if len(params) == 0:
        return None
    config, args = parseargs(params, defaults, 0, 1, presets=presets)
    if args:
        if config["responsefile"] or config["url"]:
            raise ValueError("must have responsefile or url as arg or " "parameter, not both")
        if os.path.isfile(args[0]):
            config["responsefile"] = args[0]
        else:
            try:
                urlparse(args[0])
            except:
                raise ValueError("bad filename or url")
            config["url"] = args[0]
    elif (config["responsefile"] == "") == (config["url"] == ""):
        raise ValueError("need responsefile or url, must have one, cannot " "have both")
    return config
Пример #9
0
def main():
    """The feature attraction."""
    args = parseargs.parseargs()
    base_dir = args.base_dir
    snippet_dir = args.snippet_dir

    base_names = sorted(
        [file for file in os.listdir(base_dir) if sizes.not_json(file)])
    snippet_names = sorted(
        [file for file in os.listdir(snippet_dir) if sizes.not_json(file)])

    logging.debug("base_names: %s", str(base_names))
    logging.debug("snippet_names: %s", str(snippet_names))

    column_headers = [""] + snippet_names
    print(",".join(column_headers))

    taught_sizes = defaultdict(dict)

    for base_name in base_names:
        base_sizes = Sizes(base_dir).sizes()
        with open(os.path.join(base_dir, base_name), "rb") as bfd:
            base = Chunk(name=base_name, text=bfd.read())
        for snippet_name in snippet_names:
            with open(os.path.join(snippet_dir, snippet_name), "rb") as sfd:
                snippet = Chunk(name=snippet_name, text=sfd.read())
            taught_sizes[base_name][snippet_name] = taught_size(
                base, snippet, base_sizes)

    for base_name in base_names:
        row = [base_name]
        for snippet_name in snippet_names:
            self_size = taught_sizes[snippet_name][snippet_name]
            logging.debug(
                "%s  %s %s %s",
                base_name,
                snippet_name,
                taught_sizes[base_name][snippet_name],
                self_size,
            )
            row.append(str(self_size - taught_sizes[base_name][snippet_name]))
        print(",".join(row))
Пример #10
0
def parse_params(params, presets={}):
    if len(params) == 0:
        return None
    config, args = parseargs(params, defaults, 0, 1, presets=presets)
    if args:
        if config['responsefile'] or config['url']:
            raise ValueError('must have responsefile or url as arg or '
                             'parameter, not both')
        if os.path.isfile(args[0]):
            config['responsefile'] = args[0]
        else:
            try:
                urlparse(args[0])
            except:
                raise ValueError('bad filename or url')
            config['url'] = args[0]
    elif (config['responsefile'] == '') == (config['url'] == ''):
        raise ValueError('need responsefile or url, must have one, cannot '
                         'have both')
    return config
Пример #11
0
def parse_params(params, presets={}):
    if len(params) == 0:
        return None
    config, args = parseargs(params, defaults, 0, 1, presets=presets)
    if args:
        if config['responsefile'] or config['url']:
            raise ValueError('must have responsefile or url as arg or '
                             'parameter, not both')
        if os.path.isfile(args[0]):
            config['responsefile'] = args[0]
        else:
            try:
                urlparse(args[0])
            except:
                raise ValueError('bad filename or url')
            config['url'] = args[0]
    elif (config['responsefile'] == '') == (config['url'] == ''):
        raise ValueError('need responsefile or url, must have one, cannot '
                         'have both')
    return config
from parseargs import parseargs

opts, args = parseargs(('arg1 --opt1 val1 arg2'.split()),
    (('opt1', 'default1', ''), ('opt2', 'default2', '')))
print 'opts=%s' % opts
print 'args=%s' % args

Пример #13
0
# Global variables
#

zipFlag = False
dirFlag = False

shrinkFlag = True
thesholds = []
shrinkFlag = True
connectivityFilter = False
anisotropicSmoothing = False
medianFilter = False
rotFlag = False

args = parseargs.parseargs()

isovalue = args.isovalue

# Handle enable/disable filters

if args.filters:
    for x in args.filters:
        val = True
        y = x
        if x[:2] == "no":
            val = False
            y = x[2:]
        if y.startswith("shrink"):
            shrinkFlag = val
        if y.startswith("aniso"):