Example #1
0
 def test_lsP_str(self):
     """
     Issue "ls -P foo bar" in hic_test, validate results
     """
     try:
         h = hpss.HSI(verbose=("verbose" in testhelp.testargs()))
         result = h.lsP(self.paths)
         for path in self.plist:
             self.expected_in("FILE\s+%s" % util.basename(path), result)
     except hpss.HSIerror as e:
         if MSG.hpss_unavailable in str(e):
             pytest.skip(str(e))
Example #2
0
def tcc_priority(globspec, cosinfo):
    """
    Handle any files matching globspec. Return the number of files processed.
    """
    rval = 0
    cfg = CrawlConfig.get_config()
    pri_compdir = cfg.get_d(tcc_lib.sectname(), 'completed', '/tmp')
    for filepath in glob.glob(globspec):
        tcc_lib.check_file(filepath, verbose=False, plugin=True)
        cpath = U.pathjoin(pri_compdir, U.basename(filepath))
        os.rename(filepath, cpath)

    return rval
Example #3
0
def tcc_priority(globspec, cosinfo):
    """
    Handle any files matching globspec. Return the number of files processed.
    """
    rval = 0
    cfg = CrawlConfig.get_config()
    pri_compdir = cfg.get_d(tcc_lib.sectname(), 'completed', '/tmp')
    for filepath in glob.glob(globspec):
        tcc_lib.check_file(filepath, verbose=False, plugin=True)
        cpath = U.pathjoin(pri_compdir, U.basename(filepath))
        os.rename(filepath, cpath)

    return rval
Example #4
0
 def test_lsP_argnone(self):
     """
     Issue "ls -P" in /home/tpb/hic_test with no arg, validate result
     """
     try:
         h = hpss.HSI(verbose=("verbose" in testhelp.testargs()))
         h.chdir("/home/tpb/hic_test")
         result = h.lsP()
         for path in self.plist:
             self.expected_in("FILE\s+%s" % util.basename(path), result)
     except hpss.HSIerror as e:
         if MSG.hpss_unavailable in str(e):
             pytest.skip(str(e))
def nodoc_check(mod, pylist, depth, why):
    """
    Walk the tree of modules and classes looking for routines with no doc
    string and report them
    """

    # -------------------------------------------------------------------------
    def filepath_reject(obj, pylist):
        """
        Reject the object based on its filepath
        """
        if hasattr(obj, '__file__'):
            fpath = obj.__file__.replace('.pyc', '.py')
            rval = fpath not in pylist
        elif hasattr(obj, '__func__'):
            fpath = obj.__func__.func_code.co_filename.replace('.pyc', '.py')
            rval = fpath not in pylist
        else:
            rval = False

        return rval

    # -------------------------------------------------------------------------
    def name_accept(name, already):
        """
        Whether to accept the object based on its name
        """
        rval = True
        if all([
                name in dir(unittest.TestCase), name
                not in dir(th.HelpedTestCase)
        ]):
            rval = False
        elif name in already:
            rval = False
        elif all([name.startswith('__'), name != '__init__']):
            rval = False

        return rval

    # -------------------------------------------------------------------------
    global count
    try:
        already = nodoc_check._already
    except AttributeError:
        count = 0
        nodoc_check._already = [
            'AssertionError',
            'base64',
            'bdb',
            'contextlib',
            'datetime',
            'decimal',
            'difflib',
            'dis',
            'email',
            'errno',
            'fcntl',
            'getopt',
            'getpass',
            'glob',
            'heapq',
            'inspect',
            'InterpolationMissingOptionError',
            'linecache',
            'logging',
            'MySQLdb',
            'NoOptionError',
            'NoSectionError',
            'optparse',
            'os',
            'pdb',
            'pexpect',
            'pickle',
            'pprint',
            'pwd',
            'pytest',
            're',
            'shlex',
            'shutil',
            'smtplib',
            'socket',
            'sqlite3',
            'ssl',
            'stat',
            'StringIO',
            'sys',
            'tempfile',
            'text',
            'timedelta',
            'times',
            'tokenize',
            'traceback',
            'unittest',
            'urllib',
            'warnings',
            'weakref',
        ]
        already = nodoc_check._already

    rval = ''

    if any([
            mod.__name__ in already,
            U.safeattr(mod, '__module__') == '__builtin__',
            filepath_reject(mod, pylist),
    ]):
        return rval

    # print("nodoc_check(%s = %s)" % (mod.__name__, str(mod)))
    for name, item in inspect.getmembers(mod, inspect.isroutine):
        if all([
                not inspect.isbuiltin(item), not filepath_reject(item, pylist),
                name_accept(item.__name__, already)
        ]):
            if item.__doc__ is None:
                try:
                    filename = U.basename(mod.__file__)
                except AttributeError:
                    tmod = sys.modules[mod.__module__]
                    filename = U.basename(tmod.__file__)
                rval += "\n%3d. %s(%s): %s" % (count, filename, why,
                                               item.__name__)
                try:
                    count += 1
                except NameError:
                    count = 1
            already.append(":".join([mod.__name__, name]))

    for name, item in inspect.getmembers(mod, inspect.isclass):
        if all([item.__name__ not in already, depth < 5]):
            rval += nodoc_check(item, pylist, depth + 1, 'c')
            already.append(item.__name__)

    for name, item in inspect.getmembers(mod, inspect.ismodule):
        if all([
                not inspect.isbuiltin(item), item.__name__ not in already,
                not name.startswith('@'), not name.startswith('_'), depth < 5
        ]):
            rval += nodoc_check(item, pylist, depth + 1, 'm')
            already.append(item.__name__)

    return rval
def nodoc_check(mod, pylist, depth, why):
    """
    Walk the tree of modules and classes looking for routines with no doc
    string and report them
    """
    # -------------------------------------------------------------------------
    def filepath_reject(obj, pylist):
        """
        Reject the object based on its filepath
        """
        if hasattr(obj, '__file__'):
            fpath = obj.__file__.replace('.pyc', '.py')
            rval = fpath not in pylist
        elif hasattr(obj, '__func__'):
            fpath = obj.__func__.func_code.co_filename.replace('.pyc', '.py')
            rval = fpath not in pylist
        else:
            rval = False

        return rval

    # -------------------------------------------------------------------------
    def name_accept(name, already):
        """
        Whether to accept the object based on its name
        """
        rval = True
        if all([name in dir(unittest.TestCase),
                name not in dir(th.HelpedTestCase)]):
            rval = False
        elif name in already:
            rval = False
        elif all([name.startswith('__'),
                  name != '__init__']):
            rval = False

        return rval

    # -------------------------------------------------------------------------
    global count
    try:
        already = nodoc_check._already
    except AttributeError:
        count = 0
        nodoc_check._already = ['AssertionError',
                                'base64',
                                'bdb',
                                'contextlib',
                                'datetime',
                                'decimal',
                                'difflib',
                                'dis',
                                'email',
                                'errno',
                                'fcntl',
                                'getopt',
                                'getpass',
                                'glob',
                                'heapq',
                                'inspect',
                                'InterpolationMissingOptionError',
                                'linecache',
                                'logging',
                                'MySQLdb',
                                'NoOptionError',
                                'NoSectionError',
                                'optparse',
                                'os',
                                'pdb',
                                'pexpect',
                                'pickle',
                                'pprint',
                                'pwd',
                                'pytest',
                                're',
                                'shlex',
                                'shutil',
                                'smtplib',
                                'socket',
                                'sqlite3',
                                'ssl',
                                'stat',
                                'StringIO',
                                'sys',
                                'tempfile',
                                'text',
                                'timedelta',
                                'times',
                                'tokenize',
                                'traceback',
                                'unittest',
                                'urllib',
                                'warnings',
                                'weakref',
                                ]
        already = nodoc_check._already

    rval = ''

    if any([mod.__name__ in already,
            U.safeattr(mod, '__module__') == '__builtin__',
            filepath_reject(mod, pylist),
            ]):
        return rval

    # print("nodoc_check(%s = %s)" % (mod.__name__, str(mod)))
    for name, item in inspect.getmembers(mod, inspect.isroutine):
        if all([not inspect.isbuiltin(item),
                not filepath_reject(item, pylist),
                name_accept(item.__name__, already)
                ]):
            if item.__doc__ is None:
                try:
                    filename = U.basename(mod.__file__)
                except AttributeError:
                    tmod = sys.modules[mod.__module__]
                    filename = U.basename(tmod.__file__)
                rval += "\n%3d. %s(%s): %s" % (count,
                                               filename,
                                               why,
                                               item.__name__)
                try:
                    count += 1
                except NameError:
                    count = 1
            already.append(":".join([mod.__name__, name]))

    for name, item in inspect.getmembers(mod, inspect.isclass):
        if all([item.__name__ not in already,
                depth < 5]):
            rval += nodoc_check(item, pylist, depth+1, 'c')
            already.append(item.__name__)

    for name, item in inspect.getmembers(mod, inspect.ismodule):
        if all([not inspect.isbuiltin(item),
                item.__name__ not in already,
                not name.startswith('@'),
                not name.startswith('_'),
                depth < 5]):
            rval += nodoc_check(item, pylist, depth+1, 'm')
            already.append(item.__name__)

    return rval