Esempio n. 1
0
def _get_package_modules(folder):
    dirname = folder[0]
    packages = [
        fold for fold in dirname.split(os.sep) if fold and fold != os.curdir
    ]
    prefix = '.'.join(packages)
    return _get_module_names(prefix, folder[2])
def recursive_create_dir(dirname):
  from tensorflow.python.framework import errors
  with errors.raise_exception_on_not_ok_status() as status:
    from tensorflow.python.util import compat
    dirs = dirname.split('/')
    for i in range(len(dirs)):
      partial_dir = '/'.join(dirs[0:i+1])
      if partial_dir and not file_exists(partial_dir):
        CreateDir(compat.as_bytes(partial_dir), status)
Esempio n. 3
0
def recursive_create_dir(dirname):
    from tensorflow.python.framework import errors
    with errors.raise_exception_on_not_ok_status() as status:
        from tensorflow.python.util import compat
        dirs = dirname.split('/')
        for i in range(len(dirs)):
            partial_dir = '/'.join(dirs[0:i + 1])
            if partial_dir and not file_exists(partial_dir):
                CreateDir(compat.as_bytes(partial_dir), status)
Esempio n. 4
0
def getCommonPath(dirname, filename):
    # if the 2 components are on different drives (windows)
    if splitdrive(dirname)[0] != splitdrive(filename)[0]:
        return None
    dirl = dirname.split(sep)
    filel = filename.split(sep)
    commpth = []
    for d, f in itertools.izip(dirl, filel):
        if d == f :
            commpth.append(d)
        else :
            break
    commpth = sep.join(commpth)
    if not commpth:
        commpth = sep
    elif commpth[-1] != sep:
        commpth += sep
    return commpth
Esempio n. 5
0
def getCommonPath(dirname, filename):
    # if the 2 components are on different drives (windows)
    if splitdrive(dirname)[0] != splitdrive(filename)[0]:
        return None
    dirl = dirname.split(sep)
    filel = filename.split(sep)
    commpth = []
    for d, f in itertools.izip(dirl, filel):
        if d == f:
            commpth.append(d)
        else:
            break
    commpth = sep.join(commpth)
    if not commpth:
        commpth = sep
    elif commpth[-1] != sep:
        commpth += sep
    return commpth
Esempio n. 6
0
	def isValid(self, dirname):
		urlhash = dirname.split('.')[1]
		if urlhash not in self.jshashs:
			return False
		return False if ( (self.jshash2count[self.jshashs[urlhash]] > 1) or self.isFailedUrl(dirname) ) else True
def _gen_outputdir(parentfolder, outputfolder, dirname):
    sfol_name = dirname.split(parentfolder)[-1]
    sfol_name = sfol_name if not sfol_name.startswith('/') else sfol_name[1:]
    outputdir = join(outputfolder, sfol_name)
    return outputdir
Esempio n. 8
0
def _get_package_modules(folder):
    dirname = folder[0]
    packages = [fold for fold in dirname.split(os.sep) if fold and fold != os.curdir]
    prefix = ".".join(packages)
    return _get_module_names(prefix, folder[2])
if not os.path.exists(tk_dir):
    print "Error directory does not exist"
    exit()

modules = [m for m in listdir(tk_dir) if "Module" in m]

outfile = "Robotics_with_Jetson_Teaching_Kit_" + datetime.date.today(
).strftime("%B_%d_%Y") + ".zip"
zf = zipfile.ZipFile(outfile, "w")

#add all the module directories
for m in modules:
    print "Adding " + m
    for dirname, subdirs, files in os.walk(os.path.join(tk_dir, m)):
        #remove the Google Drive directory from the path name in the zip file
        zip_path = dirname.split("Drive/")[1]

        exclude = [f for f in exclude_list if f in os.path.basename(dirname)]
        if len(exclude) == 0:
            zf.write(dirname, zip_path)

            for filename in files:
                exclude = [f for f in exclude_list if f in filename]
                if len(exclude) == 0:
                    zf.write(os.path.join(dirname, filename),
                             zip_path + "/" + filename)

#add the files in the root directory
print "Adding files in root directory"
for dirname, subdirs, files in os.walk(tk_dir):
    #remove the Google Drive directory from the path name in the zip file
Esempio n. 10
0
#!/usr/bin/env python
from os.path import dirname

print dirname("justfilename")
path = "schema/public/table/tablename/index/indexname.md"
dirname = dirname(path)
print dirname
print dirname.split("/")
print dirname.split("/")[-1]

from os.path import abspath, dirname, join
readme = join(dirname(abspath(__file__)),'README.rst')