示例#1
0
文件: make.py 项目: ndparker/tdi
    def run(self):
        from _setup.dev import apidoc

        apidoc.epydoc(
            prepend=[shell.native(self.dirs["fake"]), shell.native(self.dirs["lib"])],
            env={"TDI_NO_C_OVERRIDE": "1", "EPYDOC_INSPECTOR": "1"},
        )
示例#2
0
文件: make.py 项目: ndparker/wtf
 def run(self):
     from _setup.dev import userdoc
     userdoc.sphinx(
         build=shell.native(self.dirs['userdoc_build']),
         source=shell.native(self.dirs['userdoc_source']),
         target=shell.native(self.dirs['userdoc']),
     )
示例#3
0
 def run(self):
     from _setup.dev import userdoc
     userdoc.sphinx(
         build=shell.native(self.dirs['userdoc_build']),
         source=shell.native(self.dirs['userdoc_source']),
         target=shell.native(self.dirs['userdoc']),
     )
示例#4
0
文件: make.py 项目: ndparker/wtf
 def run(self):
     from _setup.dev import apidoc
     apidoc.epydoc(
         prepend=[
             shell.native(self.dirs['fake']),
             shell.native(self.dirs['lib']),
         ],
         env={'WTF_NO_C_OVERRIDE': '1', 'EPYDOC_INSPECTOR': '1'}
     )
示例#5
0
文件: make.py 项目: ndparker/tdi
    def init(self):
        self.dirs = {
            "lib": ".",
            "docs": "docs",
            "examples": "docs/examples",
            "tests": "tests",
            "nose_tests": "tests/nosed",
            "coverage": "docs/coverage",
            "apidoc": "docs/apidoc",
            "userdoc": "docs/userdoc",
            "userdoc_source": "docs/_userdoc",
            "userdoc_build": "docs/_userdoc/_build",
            "website": "dist/website",
            "_website": "_website",  # source dir
            "fake": "_pkg/fake",
            "dist": "dist",
            "build": "build",
            "ebuild": "_pkg/ebuilds",
        }
        libpath = shell.native(self.dirs["lib"])
        if libpath != _sys.path[0]:
            while libpath in _sys.path:
                _sys.path.remove(libpath)
            _sys.path.insert(0, libpath)

        self.ebuild_files = {
            "tdi-beta.ebuild.in": "tdi-%(VERSION)s_beta%(REV)s.ebuild",
            "tdi.ebuild.in": "tdi-%(VERSION)s.ebuild",
        }
示例#6
0
文件: make.py 项目: ndparker/tdi
    def run(self):
        import setup

        _old_argv = _sys.argv
        try:
            _sys.argv = ["setup.py", "-q", "build"]
            if not self.HIDDEN:
                _sys.argv.remove("-q")
            setup.setup()
            if "java" not in _sys.platform.lower():
                _sys.argv = [
                    "setup.py",
                    "-q",
                    "install_lib",
                    "--install-dir",
                    shell.native(self.dirs["lib"]),
                    "--optimize",
                    "2",
                ]
                if not self.HIDDEN:
                    _sys.argv.remove("-q")
                setup.setup()
        finally:
            _sys.argv = _old_argv

        for name in shell.files("%s/tdi" % self.dirs["lib"], "*.py"):
            self.compile(name)
        term.write("%(ERASE)s")

        term.green("All files successfully compiled.")
示例#7
0
文件: make.py 项目: hkmshb/rjsmin
 def run(self):
     from _setup.dev import apidoc
     apidoc.epydoc(
         prepend=[
             shell.native(self.dirs['lib']),
         ],
     )
示例#8
0
文件: make.py 项目: ndparker/tdi
 def run(self):
     term.green("Creating %(name)s...", name=self.NAME)
     dest = shell.native(self.NAME)
     dest = textopen(dest, "w")
     for name in self.manifest_names():
         dest.write("%s\n" % name)
     dest.close()
示例#9
0
文件: make.py 项目: ndparker/wtf
    def init(self):
        self.dirs = {
            'lib': '.',
            'docs': 'docs',
            'tests': 'tests',
            'coverage': 'docs/coverage',
            'apidoc': 'docs/apidoc',
            'userdoc': 'docs/userdoc',
            'userdoc_source': 'docs/_userdoc',
            'userdoc_build': 'docs/_userdoc/_build',
            'website': 'dist/website',
            '_website': '_website', # source dir
            'fake': '_pkg/fake',
            'dist': 'dist',
            'build': 'build',
            'ebuild': '_pkg/ebuilds',
        }
        libpath = shell.native(self.dirs['lib'])
        if libpath != _sys.path[0]:
            while libpath in _sys.path:
                _sys.path.remove(libpath)
            _sys.path.insert(0, libpath)

        self.ebuild_files = {
            'wtf-alpha.ebuild.in':
                'wtf-%(VERSION)s_alpha%(REV)s.ebuild',
        }
        self.manpages = (
            'docs/wtfctl.1',
        )
示例#10
0
文件: make.py 项目: hkmshb/rjsmin
    def init(self):
        self.dirs = {
            'lib': '.',
            'docs': 'docs',
            'apidoc': 'docs/apidoc',
            'userdoc': 'docs/userdoc',
            'userdoc_source': 'docs/_userdoc',
            'userdoc_build': 'docs/_userdoc/_build',
            'website': 'dist/website',
            '_website': '_website', # source dir
            'dist': 'dist',
            'build': 'build',
            'bench': 'bench',
            'ebuild': '_pkg/ebuilds',
        }
        libpath = shell.native(self.dirs['lib'])
        if libpath != _sys.path[0]:
            while libpath in _sys.path:
                _sys.path.remove(libpath)
            _sys.path.insert(0, libpath)

        self.ebuild_files = {
            'rjsmin.ebuild.in':
                'rjsmin-%(VERSION)s.ebuild',
        }
示例#11
0
 def run(self):
     _term.green("Creating %(name)s...", name=self.NAME)
     dest = _shell.native(self.NAME)
     dest = open(dest, 'w', encoding='utf-8')
     for name in self.manifest_names():
         dest.write("%s\n" % name)
     dest.close()
示例#12
0
    def sign(self, filename, detach=True):
        filename = _shell.native(filename)
        try:
            from pyme import core, errors
            from pyme.constants.sig import mode
        except ImportError:
            return self.sign_external(filename, detach=detach)

        _term.green("signing %(name)s...", name=_os.path.basename(filename))
        sigmode = [mode.CLEAR, mode.DETACH][bool(detach)]
        fp = core.Data(file=filename)
        sig = core.Data()
        try:
            c = core.Context()
        except errors.GPGMEError:
            return self.sign_external(filename, detach=detach)
        c.set_armor(1)
        try:
            c.op_sign(fp, sig, sigmode)
        except errors.GPGMEError as e:
            _make.fail(str(e))

        sig.seek(0, 0)
        if detach:
            open("%s.asc" % filename, "w", encoding='utf-8').write(sig.read())
        else:
            open(filename, "w", encoding='utf-8').write(sig.read())

        return True
示例#13
0
 def run(self):
     _term.green("Creating %(name)s...", name=self.NAME)
     dest = _shell.native(self.NAME)
     dest = open(dest, 'w', encoding='utf-8')
     for name in self.manifest_names():
         dest.write("%s\n" % name)
     dest.close()
示例#14
0
文件: make.py 项目: ndparker/wolfe
    def init(self):
        self.dirs = {
            'lib': '.',
            'docs': 'docs',
            'tests': 'tests',
            'coverage': 'docs/coverage',
            'tox': '.tox',
            'apidoc': 'docs/apidoc',
            'userdoc': 'docs/userdoc',
            'userdoc_source': 'docs/_userdoc',
            'userdoc_build': 'docs/_userdoc/_build',
            'website': 'dist/website',
            '_website': '_website',  # source dir
            'dist': 'dist',
            'build': 'build',
            'ebuild': '_pkg/ebuilds',
        }
        libpath = shell.native(self.dirs['lib'])
        if libpath != _sys.path[0]:
            while libpath in _sys.path:
                _sys.path.remove(libpath)
            _sys.path.insert(0, libpath)

        self.ebuild_files = {
            'wolfe-beta.ebuild.in': 'wolfe-%(VERSION)s_beta%(REV)s.ebuild',
            'wolfe.ebuild.in': 'wolfe-%(VERSION)s.ebuild',
        }
示例#15
0
    def init(self):
        self.dirs = {
            'lib': '.',
            'docs': 'docs',
            'apidoc': 'docs/apidoc',
            'userdoc': 'docs/userdoc',
            'userdoc_source': 'docs/_userdoc',
            'userdoc_build': 'docs/_userdoc/_build',
            'website': 'dist/website',
            '_website': '_website',  # source dir
            'tests': 'tests',
            'dist': 'dist',
            'build': 'build',
            'bench': 'bench',
            'ebuild': '_pkg/ebuilds',
        }
        libpath = shell.native(self.dirs['lib'])
        if libpath != _sys.path[0]:
            while libpath in _sys.path:
                _sys.path.remove(libpath)
            _sys.path.insert(0, libpath)

        self.ebuild_files = {
            'rcssmin.ebuild.in': 'rcssmin-%(VERSION)s.ebuild',
        }
示例#16
0
    def run(self):
        import setup

        _old_argv = _sys.argv
        try:
            _sys.argv = ['setup.py', '-q', 'build']
            if not self.HIDDEN:
                _sys.argv.remove('-q')
            setup.setup()
            if 'java' not in _sys.platform.lower():
                _sys.argv = [
                    'setup.py',
                    '-q',
                    'install_lib',
                    '--install-dir',
                    shell.native(self.dirs['lib']),
                    '--optimize',
                    '2',
                ]
                if not self.HIDDEN:
                    _sys.argv.remove('-q')
                setup.setup()
        finally:
            _sys.argv = _old_argv

        self.compile('rcssmin.py')
        term.write("%(ERASE)s")

        term.green("All files successfully compiled.")
示例#17
0
文件: make.py 项目: ndparker/wtf
    def run(self):
        import setup

        _old_argv = _sys.argv
        try:
            _sys.argv = ['setup.py', '-q', 'build']
            if not self.HIDDEN:
                _sys.argv.remove('-q')
            setup.setup()
            if 'java' not in _sys.platform.lower():
                _sys.argv = [
                    'setup.py', '-q', 'install_lib', '--install-dir',
                    shell.native(self.dirs['lib']),
                    '--optimize', '2',
                ]
                if not self.HIDDEN:
                    _sys.argv.remove('-q')
                setup.setup()
        finally:
            _sys.argv = _old_argv

        for name in shell.files("%s/wtf" % self.dirs['lib'], '*.py'):
            self.compile(name)
        term.write("%(ERASE)s")

        term.green("All files successfully compiled.")
示例#18
0
    def init(self):
        self.dirs = {
            'lib': '.',
            'docs': 'docs',
            'tests': 'tests',
            'coverage': 'docs/coverage',
            'apidoc': 'docs/apidoc',
            'userdoc': 'docs/userdoc',
            'userdoc_source': 'docs/_userdoc',
            'userdoc_build': 'docs/_userdoc/_build',
            'website': 'dist/website',
            '_website': '_website',  # source dir
            'dist': 'dist',
            'build': 'build',
            'ebuild': '_pkg/ebuilds',
        }
        libpath = shell.native(self.dirs['lib'])
        if libpath != _sys.path[0]:
            while libpath in _sys.path:
                _sys.path.remove(libpath)
            _sys.path.insert(0, libpath)

        self.ebuild_files = {
            'gensaschema-beta.ebuild.in':
                'gensaschema-%(VERSION)s_beta%(REV)s.ebuild',
            # 'gensaschema.ebuild.in': 'gensaschema-%(VERSION)s.ebuild',
        }
示例#19
0
    def sign(self, filename, detach=True):
        filename = _shell.native(filename)
        try:
            from pyme import core, errors
            from pyme.constants.sig import mode
        except ImportError:
            return self.sign_external(filename, detach=detach)

        _term.green("signing %(name)s...", name=_os.path.basename(filename))
        sigmode = [mode.CLEAR, mode.DETACH][bool(detach)]
        fp = core.Data(file=filename)
        sig = core.Data()
        try:
            c = core.Context()
        except errors.GPGMEError:
            return self.sign_external(filename, detach=detach)
        c.set_armor(1)
        try:
            c.op_sign(fp, sig, sigmode)
        except errors.GPGMEError as e:
            _make.fail(str(e))

        sig.seek(0, 0)
        if detach:
            open("%s.asc" % filename, "w", encoding='utf-8').write(sig.read())
        else:
            open(filename, "w", encoding='utf-8').write(sig.read())

        return True
示例#20
0
 def run(self):
     from _setup.dev import apidoc
     apidoc.epydoc(
         prepend=[
             shell.native(self.dirs['lib']),
         ],
         env={'EPYDOC_INSPECTOR': '1'}
     )
示例#21
0
def run(config, *args):
    """ Run pylint """
    try:
        from pylint import lint
        from pylint.reporters import text
    except ImportError:
        return 2

    if config is None:
        config = _shell.native('pylintrc')
    argv = [
        '--rcfile', config,
        '--reports', 'no',
    ]

    stream = FilterStream(_term.terminfo())

    old_stderr = _sys.stderr
    try:
        # pylint: disable = E1101
        _sys.stderr = stream
        from pylint import __pkginfo__
        if __pkginfo__.numversion >= (1, 0, 0):
            reporter = text.TextReporter(stream)
            argv.extend([
                '--msg-template',
                '{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'
            ])
        else:
            argv.extend([
                '--output-format', 'parseable',
                '--include-ids', 'yes'
            ])
            if __pkginfo__.numversion < (0, 13):
                lint.REPORTER_OPT_MAP['parseable'] = \
                    lambda: text.TextReporter2(stream)
                reporter = text.TextReporter2(stream)
            else:
                reporter = text.ParseableTextReporter(stream)
                lint.REPORTER_OPT_MAP['parseable'] = lambda: reporter

        for path in args:
            try:
                try:
                    lint.Run(argv + [path], reporter=reporter)
                except SystemExit:
                    pass  # don't accept the exit. strange errors happen...

                if stream.written:
                    print()
                    stream.written = False
            except KeyboardInterrupt:
                print()
                raise
    finally:
        _sys.stderr = old_stderr

    return 0
示例#22
0
def run(config, *args):
    """ Run pylint """
    try:
        from pylint import lint
        from pylint.reporters import text
    except ImportError:
        return 2

    if config is None:
        config = _shell.native('pylintrc')
    argv = [
        '--rcfile',
        config,
        '--reports',
        'no',
    ]

    stream = FilterStream(_term.terminfo())

    old_stderr = _sys.stderr
    try:
        # pylint: disable = E1101
        _sys.stderr = stream
        from pylint import __pkginfo__
        if __pkginfo__.numversion >= (1, 0, 0):
            reporter = text.TextReporter(stream)
            argv.extend([
                '--msg-template',
                '{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'
            ])
        else:
            argv.extend(
                ['--output-format', 'parseable', '--include-ids', 'yes'])
            if __pkginfo__.numversion < (0, 13):
                lint.REPORTER_OPT_MAP['parseable'] = \
                    lambda: text.TextReporter2(stream)
                reporter = text.TextReporter2(stream)
            else:
                reporter = text.ParseableTextReporter(stream)
                lint.REPORTER_OPT_MAP['parseable'] = lambda: reporter

        for path in args:
            try:
                try:
                    lint.Run(argv + [path], reporter=reporter)
                except SystemExit:
                    pass  # don't accept the exit. strange errors happen...

                if stream.written:
                    print()
                    stream.written = False
            except KeyboardInterrupt:
                print()
                raise
    finally:
        _sys.stderr = old_stderr

    return 0
示例#23
0
文件: make.py 项目: hkmshb/rjsmin
 def clean(self, scm, dist):
     term.green("Removing bytecode files...")
     for filename in shell.dirs('.', '__pycache__'):
         shell.rm_rf(filename)
     for filename in shell.files('.', '*.py[co]'):
         shell.rm(filename)
     for filename in shell.files('.', '*$py.class'):
         shell.rm(filename)
     shell.rm(shell.native('bench/jsmin'))
示例#24
0
 def run(self):
     files = list(shell.files(self.dirs['bench'], '*.js'))
     if self.python is None:
         python = _sys.executable
     else:
         python = shell.frompath(self.python)
     return not shell.spawn(*[
         python,
         shell.native('bench.py'),
         '-c10'
     ] + files)
示例#25
0
文件: make.py 项目: ndparker/wtf
    def run(self):
        fake = shell.native(self.dirs['fake'])
        if fake in _sys.path:
            _sys.path.remove(fake)
        _sys.path.insert(0, fake)

        from _setup.dev import analysis
        term.green('Linting wtf sources...')
        res = analysis.pylint('pylintrc', 'wtf')
        if res == 2:
            make.warn('pylint not found', self.NAME)
示例#26
0
文件: make.py 项目: ndparker/tdi
    def run(self):
        fake = shell.native(self.dirs["fake"])
        if fake in _sys.path:
            _sys.path.remove(fake)
        _sys.path.insert(0, fake)

        from _setup.dev import analysis

        term.green("Linting tdi sources...")
        res = analysis.pylint("pylintrc", "tdi")
        if res == 2:
            make.warn("pylint not found", self.NAME)
示例#27
0
文件: make.py 项目: ndparker/wtf
 def compile(self, name):
     path = shell.native(name)
     term.write("%(ERASE)s%(BOLD)s>>> Compiling %(name)s...%(NORMAL)s",
         name=name)
     from distutils import util
     try:
         from distutils import log
     except ImportError:
         util.byte_compile([path], verbose=0, force=True)
     else:
         log.set_verbosity(0)
         util.byte_compile([path], force=True)
示例#28
0
 def compile(self, name):
     path = shell.native(name)
     term.write("%(ERASE)s%(BOLD)s>>> Compiling %(name)s...%(NORMAL)s",
                name=name)
     from distutils import util
     try:
         from distutils import log
     except ImportError:
         util.byte_compile([path], verbose=0, force=True)
     else:
         log.set_verbosity(0)
         util.byte_compile([path], force=True)
示例#29
0
    def run(self):
        def escape(value):
            """ Escape for make and shell """
            return '"%s"' % value.replace(
                '\\', '\\\\').replace(
                '"', '\\"').replace(
                '$', '\\$$')
        def decorate(line, prefix='# ', width=78, char='~', padding=' '):
            """ Decorate a line """
            line = line.center(width - len(prefix))
            return '%s%s%s%s%s%s' % (
                prefix,
                char * (len(line) - len(line.lstrip()) - len(padding)),
                padding,
                line.strip(),
                padding,
                char * (len(line) - len(line.rstrip()) - len(padding)),
            )

        python = escape(_sys.executable)
        script = escape(_sys.argv[0])
        targets = self.runner.targetinfo()
        names = []
        for name, info in targets.items():
            if not info['hide']:
                names.append(name)
        names.sort()

        fp = open(_shell.native('Makefile'), 'w')
        print >> fp, decorate("Generated Makefile, DO NOT EDIT")
        print >> fp, decorate("python %s %s" % (
            _os.path.basename(script), self.NAME
        ))
        print >> fp
        print >> fp, "_default_:"
        print >> fp, "\t@%s %s" % (python, script)
        for name in names:
            print >> fp, "\n"
            print >> fp, "# %s" % \
                targets[name]['desc'].splitlines()[0].strip()
            print >> fp, "%s:" % name
            print >> fp, "\t@%s %s %s" % (python, script, escape(name))
        print >> fp
        extension = self.extend(names)
        if extension is not None:
            print >> fp, extension
            print >> fp
        print >> fp, ".PHONY: _default_ %s\n\n" % ' '.join(names)
        fp.close()
示例#30
0
文件: _pylint.py 项目: AvdN/tdi
def run(config, *args):
    """ Run pylint """
    try:
        from pylint import lint
        from pylint.reporters import text
    except ImportError:
        return 2

    if config is None:
        config = _shell.native('pylint.conf')
    argv = ['--rcfile', config,
        '--reports', 'no',
        '--output-format', 'parseable',
        '--include-ids', 'yes'
    ]

    stream = FilterStream(_term.terminfo())

    old_stderr = _sys.stderr
    try:
        # pylint: disable = E1101
        _sys.stderr = stream
        from pylint import __pkginfo__
        if __pkginfo__.numversion < (0, 13):
            # The lint tool is not very user friendly, so we need a hack here.
            lint.REPORTER_OPT_MAP['parseable'] = \
                lambda: text.TextReporter2(stream)
            reporter = text.TextReporter2(stream)
        else:
            reporter = text.ParseableTextReporter(stream)
            lint.REPORTER_OPT_MAP['parseable'] = lambda: reporter

        for path in args:
            try:
                try:
                    lint.Run(argv + [path], reporter=reporter)
                except SystemExit:
                    pass # don't accept the exit. strange errors happen...

                if stream.written:
                    print
                    stream.written = False
            except KeyboardInterrupt:
                print
                raise
    finally:
        _sys.stderr = old_stderr

    return 0
示例#31
0
    def run(self):
        def escape(value):
            """ Escape for make and shell """
            return '"%s"' % value.replace('\\', '\\\\').replace(
                '"', '\\"').replace('$', '\\$$')

        def decorate(line, prefix='# ', width=78, char='~', padding=' '):
            """ Decorate a line """
            line = line.center(width - len(prefix))
            return '%s%s%s%s%s%s' % (
                prefix,
                char * (len(line) - len(line.lstrip()) - len(padding)),
                padding,
                line.strip(),
                padding,
                char * (len(line) - len(line.rstrip()) - len(padding)),
            )

        python = escape(_sys.executable)
        script = escape(_sys.argv[0])
        targets = self.runner.targetinfo()
        names = []
        for name, info in list(targets.items()):
            if not info['hide']:
                names.append(name)
        names.sort()

        fp = open(_shell.native('Makefile'), 'w', encoding='utf-8')
        print(decorate("Generated Makefile, DO NOT EDIT"), file=fp)
        print(decorate("python %s %s" %
                       (_os.path.basename(script), self.NAME)),
              file=fp)
        print(file=fp)
        print("_default_:", file=fp)
        print("\t@%s %s" % (python, script), file=fp)
        for name in names:
            print("\n", file=fp)
            print("# %s" % \
                targets[name]['desc'].splitlines()[0].strip(), file=fp)
            print("%s:" % name, file=fp)
            print("\t@%s %s %s" % (python, script, escape(name)), file=fp)
        print(file=fp)
        extension = self.extend(names)
        if extension is not None:
            print(extension, file=fp)
            print(file=fp)
        print(".PHONY: _default_ %s\n\n" % ' '.join(names), file=fp)
        fp.close()
示例#32
0
文件: make.py 项目: hkmshb/rjsmin
 def _version_changes(self, strversion):
     """ Modify version in changes """
     filename = _os.path.join(shell.native(self.dirs['docs']), 'CHANGES')
     fp = textopen(filename)
     try:
         initlines = fp.readlines()
     finally:
         fp.close()
     fp = textopen(filename, 'w')
     try:
         for line in initlines:
             if line.rstrip() == "Changes with version":
                 line = "%s %s\n" % (line.rstrip(), strversion)
             fp.write(line)
     finally:
         fp.close()
示例#33
0
 def _version_changes(self, strversion):
     """ Modify version in changes """
     filename = _os.path.join(shell.native(self.dirs['docs']), 'CHANGES')
     fp = textopen(filename)
     try:
         initlines = fp.readlines()
     finally:
         fp.close()
     fp = textopen(filename, 'w')
     try:
         for line in initlines:
             if line.rstrip() == "Changes with version":
                 line = "%s %s\n" % (line.rstrip(), strversion)
             fp.write(line)
     finally:
         fp.close()
示例#34
0
文件: make.py 项目: ndparker/tdi
    def do_digest(self, hashfunc, name, filename):
        filename = shell.native(filename)
        term.green("%(digest)s-digesting %(name)s...", digest=name, name=_os.path.basename(filename))
        fp = textopen(filename, "rb")
        sig = hashfunc()
        block = fp.read(8192)
        while block:
            sig.update(block)
            block = fp.read(8192)
        fp.close()
        return sig.hexdigest()

        param = {"sig": sig.hexdigest(), "file": _os.path.basename(filename)}
        fp = textopen("%s.%s" % (filename, name), "w")
        fp.write("%(sig)s *%(file)s\n" % param)
        fp.close()

        return True
示例#35
0
文件: make.py 项目: ndparker/tdi
 def _version_changes(self, strversion, isdev, revision):
     """ Modify version in changes """
     filename = _os.path.join(shell.native(self.dirs["docs"]), "CHANGES")
     if isdev:
         strversion = "%s-dev-r%d" % (strversion, revision)
     fp = textopen(filename)
     try:
         initlines = fp.readlines()
     finally:
         fp.close()
     fp = textopen(filename, "w")
     try:
         for line in initlines:
             if line.rstrip() == "Changes with version":
                 line = "%s %s\n" % (line.rstrip(), strversion)
             fp.write(line)
     finally:
         fp.close()
示例#36
0
    def do_digest(self, hashfunc, name, filename):
        filename = _shell.native(filename)
        _term.green("%(digest)s-digesting %(name)s...",
            digest=name, name=_os.path.basename(filename))
        fp = open(filename, 'rb')
        sig = hashfunc()
        block = fp.read(8192)
        while block:
            sig.update(block)
            block = fp.read(8192)
        fp.close()
        return sig.hexdigest()

        param = {'sig': sig.hexdigest(), 'file': _os.path.basename(filename)}
        fp = open("%s.%s" % (filename, name), "w", encoding='utf-8')
        fp.write("%(sig)s *%(file)s\n" % param)
        fp.close()

        return True
示例#37
0
def run_setup(*args, **kwargs):
    """ Run setup """
    if "setup" in kwargs:
        script = kwargs.get("setup") or "setup.py"
        del kwargs["setup"]
    else:
        script = "setup.py"
    if "fakeroot" in kwargs:
        fakeroot = kwargs["fakeroot"]
        del kwargs["fakeroot"]
    else:
        fakeroot = None
    if kwargs:
        raise TypeError("Unrecognized keyword parameters")

    script = _shell.native(script)
    argv = [_sys.executable, script] + list(args)
    if fakeroot:
        argv.insert(0, fakeroot)
    return not _shell.spawn(*argv)
示例#38
0
def run_setup(*args, **kwargs):
    """ Run setup """
    if 'setup' in kwargs:
        script = kwargs.get('setup') or 'setup.py'
        del kwargs['setup']
    else:
        script = 'setup.py'
    if 'fakeroot' in kwargs:
        fakeroot = kwargs['fakeroot']
        del kwargs['fakeroot']
    else:
        fakeroot = None
    if kwargs:
        raise TypeError("Unrecognized keyword parameters")

    script = _shell.native(script)
    argv = [_sys.executable, script] + list(args)
    if fakeroot:
        argv.insert(0, fakeroot)
    return not _shell.spawn(*argv)
示例#39
0
    def do_digest(self, hashfunc, name, filename):
        filename = _shell.native(filename)
        _term.green("%(digest)s-digesting %(name)s...",
                    digest=name,
                    name=_os.path.basename(filename))
        fp = open(filename, 'rb')
        sig = hashfunc()
        block = fp.read(8192)
        while block:
            sig.update(block)
            block = fp.read(8192)
        fp.close()
        return sig.hexdigest()

        param = {'sig': sig.hexdigest(), 'file': _os.path.basename(filename)}
        fp = open("%s.%s" % (filename, name), "w", encoding='utf-8')
        fp.write("%(sig)s *%(file)s\n" % param)
        fp.close()

        return True
示例#40
0
文件: targets.py 项目: AvdN/tdi
    def sign(self, filename, detach=True):
        filename = _shell.native(filename)
        try:
            from pyme import core, errors
            from pyme.constants.sig import mode
        except ImportError:
            return self.sign_external(filename, detach=detach)

        _term.green("signing %(name)s...", name=_os.path.basename(filename))
        sigmode = [mode.CLEAR, mode.DETACH][bool(detach)]
        fp = core.Data(file=filename)
        sig = core.Data()
        try:
            c = core.Context()
        except errors.GPGMEError:
            return self.sign_external(filename, detach=detach)
        c.set_armor(1)
        try:
            c.op_sign(fp, sig, sigmode)
        except errors.GPGMEError, e:
            _make.fail(str(e))
示例#41
0
    def sign(self, filename, detach=True):
        filename = _shell.native(filename)
        try:
            from pyme import core, errors
            from pyme.constants.sig import mode
        except ImportError:
            return self.sign_external(filename, detach=detach)

        _term.green("signing %(name)s...", name=_os.path.basename(filename))
        sigmode = [mode.CLEAR, mode.DETACH][bool(detach)]
        fp = core.Data(file=filename)
        sig = core.Data()
        try:
            c = core.Context()
        except errors.GPGMEError:
            return self.sign_external(filename, detach=detach)
        c.set_armor(1)
        try:
            c.op_sign(fp, sig, sigmode)
        except errors.GPGMEError, e:
            _make.fail(str(e))
示例#42
0
文件: run_tests.py 项目: giorgil/tdi
 def run_test(script, output):
     """ Run it """
     erred = 0
     try:
         fp = open(output, 'r')
     except IOError:
         output = None
     else:
         try:
             output = fp.read()
         finally:
             fp.close()
     env = dict(_os.environ)
     if libdir is not None:
         libdir_ = shell.native(libdir)
         if env.has_key('PYTHONPATH'):
             ppath = _os.pathsep.join((libdir_, env['PYTHONPATH']))
         else:
             ppath = libdir_
         env['PYTHONPATH'] = libdir_
     out = ""
     overrides = '10'
     if 'java' in _sys.platform.lower() or \
             getattr(_sys, 'pypy_version_info', None) is not None:
         overrides = '1'
     for no_c_override in overrides:
         env['TDI_NO_C_OVERRIDE'] = no_c_override
         try:
             genout = shell.spawn(
                 _sys.executable, script, stdout=True, env=env
             )
         except shell.SignalError, e:
             out += "%%(RED)s%s%%(NORMAL)s " % (e.signalstr,)
             erred = 1
         except shell.ExitError, e:
             out += "%%(RED)s  %02d%%(NORMAL)s " % e.code
             erred = 1
示例#43
0
文件: make.py 项目: ndparker/wtf
    def run(self):
        from _setup.util import SafeConfigParser as parser
        parser = parser()
        parser.read('package.cfg', **cfgread)
        strversion = parser.get('package', 'version.number')
        shortversion = tuple(map(int, strversion.split('.')[:2]))

        shell.rm_rf(self.dirs['_website'])
        shell.cp_r(
            self.dirs['userdoc_source'],
            _os.path.join(self.dirs['_website'], 'src')
        )
        shell.rm_rf(_os.path.join(self.dirs['_website'], 'build'))
        shell.rm_rf(self.dirs['website'])
        _os.makedirs(self.dirs['website'])
        filename = _os.path.join(
            self.dirs['_website'], 'src', 'website_download.txt'
        )
        fp = textopen(filename)
        try:
            download = fp.read()
        finally:
            fp.close()
        filename = _os.path.join(self.dirs['_website'], 'src', 'index.txt')
        fp = textopen(filename)
        try:
            indexlines = fp.readlines()
        finally:
            fp.close()

        fp = textopen(filename, 'w')
        try:
            for line in indexlines:
                if line.startswith('.. placeholder: Download'):
                    line = download
                fp.write(line)
        finally:
            fp.close()

        shell.cp_r(
            self.dirs['apidoc'],
            _os.path.join(self.dirs['website'], 'doc-%d.%d' % shortversion)
        )
        shell.cp_r(
            self.dirs['apidoc'],
            _os.path.join(
                self.dirs['_website'], 'src', 'doc-%d.%d' % shortversion
            )
        )
        fp = textopen(_os.path.join(
            self.dirs['_website'], 'src', 'conf.py'
        ), 'a')
        try:
            fp.write("\nepydoc = dict(wtf=%r)\n" % (
                _os.path.join(
                    shell.native(self.dirs['_website']),
                    "src",
                    "doc-%d.%d" % shortversion,
                ),
            ))
            fp.write("\nexclude_trees.append(%r)\n" %
                "doc-%d.%d" % shortversion
            )
        finally:
            fp.close()
        from _setup.dev import userdoc
        userdoc.sphinx(
            build=shell.native(_os.path.join(self.dirs['_website'], 'build')),
            source=shell.native(_os.path.join(self.dirs['_website'], 'src')),
            target=shell.native(self.dirs['website']),
        )
        shell.rm(_os.path.join(self.dirs['website'], '.buildinfo'))
示例#44
0
def epydoc(**kwargs):
    """ Run epydoc """
    # pylint: disable = R0912
    prog = kwargs.get('epydoc') or 'epydoc'
    if not _os.path.dirname(_os.path.normpath(prog)):
        prog = _shell.frompath(prog)
    if not prog:
        _term.red("%(epydoc)s not found",
            epydoc=kwargs.get('epydoc') or 'epydoc',
        )
        return False

    version = _VERSION_SEARCH(_shell.spawn(prog, "--version", stdout=True))
    if version is not None:
        try:
            version = tuple(map(int, version.group('major', 'minor')))
        except (TypeError, ValueError):
            version = None
    if version is None:
        _term.red("%(prog)s version not recognized" % locals())
        return False

    if version < (3, 0):
        _term.red("%(prog)s is too old %(version)r < (3, 0)" % locals())
        return False

    env = dict(_os.environ)

    prepend = kwargs.get('prepend')
    if prepend:
        toprepend = _os.pathsep.join(map(str, prepend))
        if 'PYTHONPATH' in env:
            env['PYTHONPATH'] = _os.pathsep.join((
                toprepend, env['PYTHONPATH']
            ))
        else:
            env['PYTHONPATH'] = toprepend

    append = kwargs.get('append')
    if append:
        toappend = _os.pathsep.join(map(str, append))
        if 'PYTHONPATH' in env:
            env['PYTHONPATH'] = _os.pathsep.join((
                env['PYTHONPATH'], toappend
            ))
        else:
            env['PYTHONPATH'] = toappend

    moreenv = kwargs.get('env')
    if moreenv:
        env.update(moreenv)

    config = kwargs.get('config') or _shell.native('docs/epydoc.conf')

    argv = [prog, '--config', config]
    res = not _shell.spawn(*argv, **{'env': env})
    if res:
        cfg = _util.SafeConfigParser()
        cfg.read(config)
        try:
            target = dict(cfg.items('epydoc'))['target']
        except KeyError:
            pass
        else:
            _cleanup_epydoc(target)
    return res
示例#45
0
    def run(self):
        from _setup.util import SafeConfigParser as parser
        parser = parser()
        parser.read('package.cfg', **cfgread)
        strversion = parser.get('package', 'version.number')
        shortversion = tuple(map(int, strversion.split('.')[:2]))

        shell.rm_rf(self.dirs['_website'])
        shell.cp_r(self.dirs['userdoc_source'],
                   _os.path.join(self.dirs['_website'], 'src'))
        shell.rm_rf(_os.path.join(self.dirs['_website'], 'build'))
        shell.rm_rf(self.dirs['website'])
        _os.makedirs(self.dirs['website'])
        filename = _os.path.join(self.dirs['_website'], 'src',
                                 'website_download.txt')
        fp = textopen(filename)
        try:
            download = fp.read()
        finally:
            fp.close()
        filename = _os.path.join(self.dirs['_website'], 'src', 'index.txt')
        fp = textopen(filename)
        try:
            indexlines = fp.readlines()
        finally:
            fp.close()

        fp = textopen(filename, 'w')
        try:
            for line in indexlines:
                if line.startswith('.. placeholder: Download'):
                    line = download
                fp.write(line)
        finally:
            fp.close()

        shell.cp_r(
            self.dirs['apidoc'],
            _os.path.join(self.dirs['website'], 'doc-%d.%d' % shortversion))
        shell.cp_r(
            self.dirs['apidoc'],
            _os.path.join(self.dirs['_website'], 'src',
                          'doc-%d.%d' % shortversion))
        fp = textopen(_os.path.join(self.dirs['_website'], 'src', 'conf.py'),
                      'a')
        try:
            fp.write("\nepydoc = dict(rcssmin=%r)\n" % (_os.path.join(
                shell.native(self.dirs['_website']),
                "src",
                "doc-%d.%d" % shortversion,
            ), ))
            fp.write("\nexclude_trees.append(%r)\n" % "doc-%d.%d" %
                     shortversion)
        finally:
            fp.close()
        from _setup.dev import userdoc
        userdoc.sphinx(
            build=shell.native(_os.path.join(self.dirs['_website'], 'build')),
            source=shell.native(_os.path.join(self.dirs['_website'], 'src')),
            target=shell.native(self.dirs['website']),
        )
        shell.rm(_os.path.join(self.dirs['website'], '.buildinfo'))
示例#46
0
def run_tests(basedir, libdir):
    """ Run output based tests """
    import rcssmin as _rcssmin
    py_cssmin = _rcssmin._make_cssmin(python_only=True)
    c_cssmin = _rcssmin._make_cssmin(python_only=False)

    def run_test(example, output_file):
        """ Run it """
        try:
            fp = open(example, 'r')
        except IOError:
            return
        else:
            try:
                input = fp.read()
            finally:
                fp.close()

        def load_output(filename):
            try:
                fp = open(filename, 'r')
            except IOError:
                return None
            else:
                try:
                    output = fp.read()
                finally:
                    fp.close()
            output = output.strip()
            if _re.search(r'(?<!\\)(?:\\\\)*\\[0-9a-zA-Z]{1,6}$', output):
                output += ' '
            return output

        output = load_output(output_file)
        output_b = load_output(output_file + '.b')

        def do_test(cssmin, output, **options):
            try:
                genout = cssmin(input, **options)
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                return 1, "%(RED)s exc%(NORMAL)s "
            else:
                if output is None:
                    return 1, "%(RED)smiss%(NORMAL)s "
                elif genout == output or genout == output.rstrip():
                    return 0, "%(GREEN)sOK%(NORMAL)s   "
                else:
                    return 1, "%(RED)sfail%(NORMAL)s "

        erred, out = do_test(py_cssmin, output)
        erred, c_out = do_test(c_cssmin, output)
        erred, out_b = do_test(py_cssmin, output_b, keep_bang_comments=True)
        erred, c_out_b = do_test(c_cssmin, output_b, keep_bang_comments=True)

        term.write(
            "%(out)s %(out_b)s  |  %(c_out)s %(c_out_b)s - %%(example)s\n"
                % locals(),
            example=_os.path.basename(example),
        )
        return erred

    # end
    # begin main test code

    erred = 0
    basedir = shell.native(basedir)
    strip = len(basedir) - len(_os.path.basename(basedir))
    for dirname, dirs, files in shell.walk(basedir):
        dirs[:] = [
            item for item in dirs if item not in ('.svn', '.git', 'out')
        ]
        dirs.sort()
        files = [item for item in files if item.endswith('.css')]
        if not files:
            continue
        if not _os.path.isdir(_os.path.join(basedir, dirname, 'out')):
            continue
        term.yellow("---> %s" % (dirname[strip:],))
        files.sort()
        for filename in files:
            if run_test(
                _os.path.join(dirname, filename),
                _os.path.join(dirname, 'out', filename[:-4] + '.out'),
            ): erred = 1
        term.yellow("<--- %s" % (dirname[strip:],))
    return erred
示例#47
0
 def run(self):
     from _setup.dev import apidoc
     apidoc.epydoc(prepend=[
         shell.native(self.dirs['lib']),
     ], )