Open the libconfig file specified by sys.argv[1] and pretty-print it
18758
def main():
    ''''''
    global output
    if len(sys.argv[1:]) == 1:
        with io.open(sys.argv[1], 'r', encoding='utf-8') as f:
            output = load(f)
    else:
        output = load(sys.stdin)

    dump(output, sys.stdout)
705085
def base_argparser(argv=()):
    
    global verbose
    verbose = _not_verbose

    _p = argparse.ArgumentParser(add_help=False)
    _p.add_argument('--debug', action='store_true', help="turn on all the show and verbose options (mainly for debugging pydeps itself)")
    _p.add_argument('--config', help="specify config file", metavar="FILE")
    _p.add_argument('--no-config', help="disable processing of config files", action='store_true')
    _p.add_argument('--version', action='store_true', help='print pydeps version')
    _p.add_argument('-L', '--log', help=textwrap.dedent('''
        set log-level to one of CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET.
    '''))
    _args, argv = _p.parse_known_args(argv)

    if _args.log:
        loglevels = "CRITICAL DEBUG ERROR FATAL INFO WARN"
        if _args.log not in loglevels:  # pragma: nocover
            error('legal values for the -L parameter are:', loglevels)
        loglevel = getattr(logging, _args.log)
    else:
        loglevel = None

    logging.basicConfig(
        level=loglevel,
        format='%(filename)s:%(lineno)d: %(levelname)s: %(message)s'
    )

    if _args.version:  # pragma: nocover
        print("pydeps v" + __version__)
        sys.exit(0)

    return _p, _args, argv
1315205
def main(argv=None):
    
    if not argv:
        argv = sys.argv[1:]

    parser = argparse.ArgumentParser(description=_HELP_TEXT)
    parser.add_argument('input', nargs='?', default=None)
    parser.add_argument('output', nargs='?', default=None)
    parser.add_argument('--version', action='version',
                        version='%(prog)s ' + get_version())
    args = parser.parse_args(argv)

    if not args.input:
        print("No file specified", file=sys.stderr)
        sys.exit(1)

    try:
        with open(args.input, 'r') as f:
            res = mangle(f.read())
            if not args.output:
                print(res, end='')
            else:
                with open(args.output, 'w') as o:
                    o.write(res)
    except Exception as ex:
        print("Error mangling {}: {!s}".format(args.input, ex),
              file=sys.stderr)
        sys.exit(1)
291090
def main(argv=None):
    
    # Get command line arguments, validate them, and normalize them
    opts = cmdparse.parse_args(argv)
    assert validate_opts.validate(opts)
    opts = normalize_opts.normalize(opts)

    if opts.verbose:
        # Update client: print input and output directories
        messages.print_input_output(opts)

    file_paths = fileparse.get_file_list(opts)
    assert validate_files.validate(file_paths, opts)

    if opts.verbose and opts.is_dir:
        # Update client: print files that will be parsed
        messages.print_files(opts, file_paths)

    # For now, only using default GitHub Markdown for parsing
    # Collect tag/anchor combinations
    collector = make_github_markdown_collector(opts)
    anchors, duplicate_tags = collector.collect(file_paths)
    assert validate_anchors.validate(anchors, duplicate_tags, opts)

    # Write files using previously found AnchorHub tags and generated anchors
    writer = make_github_markdown_writer(opts)
    counter = writer.write(file_paths, anchors, opts)

    if opts.verbose:
        if opts.is_dir:
            # Update client: print files that had modifications
            messages.print_modified_files(opts, anchors)
        # Print summary statistics
        messages.print_summary_stats(counter)
1249069
def make(self, **kwargs):
        ''' 
        '''
        configpath = os.path.dirname(os.path.abspath(__file__)) + "/config.py"
        print ("Writing to " + configpath)
        with open(configpath, 'w+') as fh:
            try:
                fh.write("#!/usr/bin/python3\n\n")
            except Exception as e:
                print(e)
            else:
                for key, value in kwargs.items():
                    fh.write(key + ' = ' + value + "\n")
472026
def write_conf(self):
        
        f = open(self.output_filename, 'w')
        print(self.t.render(prefixes=self.prefixes), file=f)
        f.close()
717809
def config_pp(subs):
    
    print('(c|f): available only as CLI argument/in the config file',
          end='\n\n')
    for sub in subs:
        hlp_lst = []
        for opt, meta in conf[sub].defaults_():
            if meta.cmd_arg ^ meta.conf_arg:
                opt += ' (c)' if meta.cmd_arg else ' (f)'
            hlp_lst.append((opt, meta.help))
        if hlp_lst:
            print('{}:'.format(sub))
            _pretty_print(hlp_lst, sep=' -- ',
                          text_width=min(get_terminal_size().columns, 100))
            print()
1218066
def cli(  # pylint: disable=too-many-arguments
        ctx, target, config, c, commits, extra_path, ignore, msg_filename,
        verbose, silent, debug,
):
    

    try:
        if debug:
            logging.getLogger("gitlint").setLevel(logging.DEBUG)

        log_system_info()

        # Get the lint config from the commandline parameters and
        # store it in the context (click allows storing an arbitrary object in ctx.obj).
        config, config_builder = build_config(ctx, target, config, c, extra_path, ignore, verbose, silent, debug)

        LOG.debug(u"Configuration\n%s", ustr(config))

        ctx.obj = (config, config_builder, commits, msg_filename)

        # If no subcommand is specified, then just lint
        if ctx.invoked_subcommand is None:
            ctx.invoke(lint)

    except GitContextError as e:
        click.echo(ustr(e))
        ctx.exit(GIT_CONTEXT_ERROR_CODE)
711341
def dump_config(self):
        """"""
        yaml_content = self.get_merged_config()
        print('YAML Configuration\n%s\n' % yaml_content.read())
        try:
            self.load()
            print('Python Configuration\n%s\n' % pretty(self.yamldocs))
        except ConfigError:
            sys.stderr.write(
                'config parse error. try running with --logfile=/dev/tty\n')
            raise
840415
def get_system_python_library():
    
    import os
    import utool as ut
    from os.path import basename, realpath
    pyname = basename(realpath(sys.executable))
    ld_library_path = os.environ['LD_LIBRARY_PATH']
    libdirs = [x for x in ld_library_path.split(os.pathsep) if x] + ['/usr/lib']
    libfiles = ut.flatten([ut.glob(d, '*' + ut.get_lib_ext(), recursive=True) for d in libdirs])
    python_libs = [realpath(f) for f in libfiles if 'lib' + pyname in basename(f)]
    python_libs = ut.unique_ordered(python_libs)
    assert len(python_libs) == 1, str(python_libs)
    return python_libs[0]
188352
def main_as_cli(argv=None):
    ''''''
    try:
        result = main(argv)
    except Exception as e:
        result = __pretty_print_fc_exception(e)
    # FIXME: we should invert True/False return values to 0/1 here, to comply
    # with UNIX exit code semantics (and avoid problems with make, scripts, etc)
    return printToCLI(result)
1036298
def _FetchLinuxFlags(self):
    """"""
    if platform.system() != "Linux":
      return 0

    # Since we open a file in the next step we do not want to open a symlink.
    # `lsattr` returns an error when trying to check flags of a symlink, so we
    # assume that symlinks cannot have them.
    if self.IsSymlink():
      return 0

    # Some files (e.g. sockets) cannot be opened. For these we do not really
    # care about extended flags (they should have none). `lsattr` does not seem
    # to support such cases anyway. It is also possible that a file has been
    # deleted (because this method is used lazily).
    try:
      fd = os.open(self._path, os.O_RDONLY)
    except (IOError, OSError):
      return 0

    try:
      # This import is Linux-specific.
      import fcntl  # pylint: disable=g-import-not-at-top
      # TODO: On Python 2.7.6 `array.array` accepts only byte
      # strings as an argument. On Python 2.7.12 and 2.7.13 unicodes are
      # supported as well. On Python 3, only unicode strings are supported. This
      # is why, as a temporary hack, we wrap the literal with `str` call that
      # will convert it to whatever is the default on given Python version. This
      # should be changed to raw literal once support for Python 2 is dropped.
      buf = array.array(compatibility.NativeStr("l"), [0])
      # TODO(user):pytype: incorrect type spec for fcntl.ioctl
      # pytype: disable=wrong-arg-types
      fcntl.ioctl(fd, self.FS_IOC_GETFLAGS, buf)
      # pytype: enable=wrong-arg-types
      return buf[0]
    except (IOError, OSError):
      # File system does not support extended attributes.
      return 0
    finally:
      os.close(fd)
680307
def _versioned_implib_symlinks(env, libnode, version, prefix, suffix, **kw):
    
    Verbose = False

    if Verbose:
        print("_versioned_implib_symlinks: libnode=%r" % libnode.get_path())
        print("_versioned_implib_symlinks: version=%r" % version)

    try: libtype = kw['libtype']
    except KeyError: libtype = 'ShLib'


    linkdir = os.path.dirname(libnode.get_path())
    if Verbose:
        print("_versioned_implib_symlinks: linkdir=%r" % linkdir)

    name = SCons.Tool.ImpLibNameGenerator(env, libnode,
                                          implib_libtype=libtype,
                                          generator_libtype=libtype+'ImpLib')
    if Verbose:
        print("_versioned_implib_symlinks: name=%r" % name)

    major = version.split('.')[0]

    link0 = env.fs.File(os.path.join(linkdir, name))
    symlinks = [(link0, libnode)]

    if Verbose:
        print("_versioned_implib_symlinks: return symlinks=%r" % SCons.Tool.StringizeLibSymlinks(symlinks))

    return symlinks
270458
def argv(self):
        """"""
        # Python interpreter used to start kernels
        if CONF.get('main_interpreter', 'default'):
            pyexec = get_python_executable()
        else:
            # Avoid IPython adding the virtualenv on which Spyder is running
            # to the kernel sys.path
            os.environ.pop('VIRTUAL_ENV', None)
            pyexec = CONF.get('main_interpreter', 'executable')
            if not is_python_interpreter(pyexec):
                pyexec = get_python_executable()
                CONF.set('main_interpreter', 'executable', '')
                CONF.set('main_interpreter', 'default', True)
                CONF.set('main_interpreter', 'custom', False)

        # Fixes Issue #3427
        if os.name == 'nt':
            dir_pyexec = osp.dirname(pyexec)
            pyexec_w = osp.join(dir_pyexec, 'pythonw.exe')
            if osp.isfile(pyexec_w):
                pyexec = pyexec_w

        # Command used to start kernels
        kernel_cmd = [
            pyexec,
            '-m',
            'spyder_kernels.console',
            '-f',
            '{connection_file}'
        ]

        return kernel_cmd
1160693
def GetPythonLibraryDirectoryPath():
  """"""
  path = sysconfig.get_python_lib(True)
  _, _, path = path.rpartition(sysconfig.PREFIX)

  if path.startswith(os.sep):
    path = path[1:]

  return path
715928
def init_not_msvc(self):
        
        # find_library() does not search automatically LD_LIBRARY_PATH
        paths = os.environ.get('LD_LIBRARY_PATH', '').split(':')
        for gomp in ('libgomp.so', 'libgomp.dylib'):
            if cxx is None:
                continue
            cmd = [cxx, '-print-file-name=' + gomp]
            # the subprocess can fail in various ways
            # in that case just give up that path
            try:
                path = os.path.dirname(check_output(cmd).strip())
                if path:
                    paths.append(path)
            except OSError:
                pass

        # Try to load find libgomp shared library using loader search dirs
        libgomp_path = find_library("gomp")

        # Try to use custom paths if lookup failed
        for path in paths:
            if libgomp_path:
                break
            path = path.strip()
            if os.path.isdir(path):
                libgomp_path = find_library(os.path.join(str(path), "libgomp"))

        if not libgomp_path:
            raise ImportError("I can't find a shared library for libgomp,"
                              " you may need to install it or adjust the "
                              "LD_LIBRARY_PATH environment variable.")
        else:
            # Load the library (shouldn't fail with an absolute path right?)
            self.libomp = ctypes.CDLL(libgomp_path)
            self.version = 45
134091
def _parse_argv(argv=copy(sys.argv)):
    

    cfg = DotDict()
    cfg_files = []

    argv = argv[1:] # Skip command name
    while argv:
        arg = argv.pop(0)

        # split up arg in format --arg=val
        key_val = re.split('=| ', arg)
        arg = key_val[0]
        try:
            val = key_val[1]
        except IndexError:
            if len(argv) > 0 and argv[0][0] != '-':
                val = argv.pop(0)
            else:
                # No val available, probably a flag
                val = None

        if arg[0] == '-':
            key = arg.lstrip('-')
            if not val:
                val = True
            new_cfg = _dict_from_dotted(key, val)
            cfg = dict_merge(cfg, new_cfg)
        else:
            if arg.endswith(".yml"):
                cfg_files.append(arg)

    return cfg, cfg_files