def getName( self ):
     dirname = basename(getcwd())
     if dirname.startswith('app'):
         name = dirname[3:]
     elif dirname.startswith('lib'):
         name = dirname[3:]
     else:
         name = dirname
     return name + '_dbg' if self.DEBUG else name
Exemple #2
0
def getRecordingFilename(basename, dirname=None):
    nonAllowedCharacters = "/.\\:*?<>|\""  # Filter out non-allowed characters.
    basename = basename.replace("\xc2\x86", "").replace(
        "\xc2\x87", "") if PY2 else basename.replace("\x86", "").replace(
            "\x87", "")
    filename = ""
    for character in basename:
        if character in nonAllowedCharacters or ord(character) < 32:
            character = "_"
        filename += character
    # Max filename length for ext4 is 255 (minus 8 characters for .ts.meta)
    # but must not truncate in the middle of a multi-byte utf8 character!
    # So convert the truncation to unicode and back, ignoring errors, the
    # result will be valid utf8 and so xml parsing will be OK.
    filename = unicode(filename[:247], "UTF8", "ignore").encode(
        "UTF8", "ignore") if PY2 else filename[:247]
    if dirname is None:
        dirname = defaultRecordingLocation()
    else:
        if not dirname.startswith(sep):
            dirname = pathjoin(defaultRecordingLocation(), dirname)
    filename = pathjoin(dirname, filename)
    next = 0
    path = filename
    while isfile("%s.ts" % path):
        next += 1
        path = "%s_%03d" % (filename, next)
    return path
Exemple #3
0
def getRecordingFilename(basename, dirname=None):
    # Filter out non-allowed characters.
    non_allowed_characters = "/.\\:*?<>|\""
    basename = basename.replace("\xc2\x86", "").replace(
        "\xc2\x87", "") if PY2 else basename.replace("\x86", "").replace(
            "\x87", "")
    filename = ""
    for c in basename:
        if c in non_allowed_characters or ord(c) < 32:
            c = "_"
        filename += c
    # Max filename length for ext4 is 255 (minus 8 characters for .ts.meta)
    # but must not truncate in the middle of a multi-byte utf8 character!
    # So convert the truncation to unicode and back, ignoring errors, the
    # result will be valid utf8 and so xml parsing will be OK.
    filename = unicode(filename[:247], "utf8", "ignore").encode(
        "utf8", "ignore") if PY2 else filename[:247]
    if dirname is not None:
        if not dirname.startswith("/"):
            dirname = pathjoin(defaultRecordingLocation(), dirname)
    else:
        dirname = defaultRecordingLocation()
    filename = pathjoin(dirname, filename)
    path = filename
    i = 1
    while True:
        if not isfile(path + ".ts"):
            return path
        path = "%s_%03d" % (filename, i)
        i += 1
def get_packages_and_files(path, exts=[]):
    # if no extensions are set then allow all files
    inexts = lambda file, exts: not exts or splitext(file)[1][1:] in exts
    packages, data_files  = [], []
    for dirpath, dirnames, filenames in os.walk(path):
        # Ignore dirnames that start with '.'
        for i, dirname in enumerate(dirnames):
            if dirname.startswith('.'): del dirnames[i]
        no_prefix_path = fullsplit(dirpath)[1:]
        if '__init__.py' in filenames:
            packages.append('.'.join(no_prefix_path)) # skip src/ prefix
        elif filenames:
            curr_files = [pjoin(dirpath, f) for f in filenames if inexts(f, exts)]
            data_files.append([os.sep.join(no_prefix_path), curr_files])
    return (packages, data_files)
Exemple #5
0
 def _not_current_label(self, dirname, label_type):
     return (dirname.startswith(label_type + "_") and
             dirname[len(label_type) + 1:] not in self._labels[label_type])
def is_valid_dir(parent_dir, dirname):
    valid = os.path.isdir(os.path.join(parent_dir, dirname))
    valid &= not dirname.startswith("_")
    valid &= ('osx_is_app' != dirname or sys.platform == "darwin")
    return valid
Exemple #7
0
def add_full_path(dirname, basedir=None):
    if basedir is None:
        basedir = os.getcwd()
    if not dirname.startswith("/"):
        dirname = os.path.join(basedir, dirname)
    return dirname
Exemple #8
0
def is_valid_dir(parent_dir, dirname):
    valid = os.path.isdir(os.path.join(parent_dir, dirname))
    valid &= not dirname.startswith("_")
    valid &= ('osx_is_app' != dirname or sys.platform == "darwin")
    return valid
Exemple #9
0
def add_full_path(dirname, basedir=None):
    if basedir is None:
        basedir = os.getcwd()
    if not dirname.startswith("/"):
        dirname = os.path.join(basedir, dirname)
    return dirname