Python os.pardir() Examples
The following are 30
code examples of os.pardir().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: util.py From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 | 7 votes |
def get_mxnet_root() -> str: curpath = os.path.abspath(os.path.dirname(__file__)) def is_mxnet_root(path: str) -> bool: return os.path.exists(os.path.join(path, ".mxnet_root")) while not is_mxnet_root(curpath): parent = os.path.abspath(os.path.join(curpath, os.pardir)) if parent == curpath: raise RuntimeError("Got to the root and couldn't find a parent folder with .mxnet_root") curpath = parent return curpath
Example #2
Source File: common.py From py with MIT License | 7 votes |
def bestrelpath(self, dest): """ return a string which is a relative path from self (assumed to be a directory) to dest such that self.join(bestrelpath) == dest and if not such path can be determined return dest. """ try: if self == dest: return os.curdir base = self.common(dest) if not base: # can be the case on windows return str(dest) self2base = self.relto(base) reldest = dest.relto(base) if self2base: n = self2base.count(self.sep) + 1 else: n = 0 l = [os.pardir] * n if reldest: l.append(reldest) target = dest.sep.join(l) return target except AttributeError: return str(dest)
Example #3
Source File: libabptts.py From ABPTTS with GNU General Public License v2.0 | 7 votes |
def ZipDir(sourceDirectory, outputFilePath, outputHandler): currentDir = os.getcwd() try: os.chdir(sourceDirectory) #relroot = os.path.abspath(os.path.join(sourceDirectory, os.pardir)) relroot = os.path.abspath(os.path.join(sourceDirectory)) #with zipfile.ZipFile(outputFilePath, "w", zipfile.ZIP_DEFLATED) as zip: with zipfile.ZipFile(outputFilePath, "w") as zip: for root, dirs, files in os.walk(sourceDirectory): # add directory (needed for empty dirs) # this is commented out because Tomcat 8 will reject WAR files with "./" in them. #zip.write(root, os.path.relpath(root, relroot)) for file in files: filename = os.path.join(root, file) if os.path.isfile(filename): # regular files only arcname = os.path.join(os.path.relpath(root, relroot), file) zip.write(filename, arcname) return True except Exception as e: outputHandler.outputMessage('Error creating zip file "%s" from directory "%s" - %s' % (outputFilePath, sourceDirectory, e)) return False os.chdir(currentDir)
Example #4
Source File: getmetrics_hadoop.py From InsightAgent with Apache License 2.0 | 6 votes |
def get_reporting_config_vars(): reporting_config = {} with open(os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, "reporting_config.json")), 'r') as f: config = json.load(f) reporting_interval_string = config['reporting_interval'] if reporting_interval_string[-1:] == 's': reporting_interval = float(config['reporting_interval'][:-1]) reporting_config['reporting_interval'] = float(reporting_interval / 60.0) else: reporting_config['reporting_interval'] = int(config['reporting_interval']) reporting_config['keep_file_days'] = int(config['keep_file_days']) reporting_config['prev_endtime'] = config['prev_endtime'] reporting_config['deltaFields'] = config['delta_fields'] reporting_config['keep_file_days'] = int(config['keep_file_days']) reporting_config['prev_endtime'] = config['prev_endtime'] reporting_config['deltaFields'] = config['delta_fields'] return reporting_config
Example #5
Source File: getmetrics_hbase.py From InsightAgent with Apache License 2.0 | 6 votes |
def get_reporting_config_vars(): reporting_config = {} with open(os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, "reporting_config.json")), 'r') as f: config = json.load(f) reporting_interval_string = config['reporting_interval'] if reporting_interval_string[-1:] == 's': reporting_interval = float(config['reporting_interval'][:-1]) reporting_config['reporting_interval'] = float(reporting_interval / 60.0) else: reporting_config['reporting_interval'] = int(config['reporting_interval']) reporting_config['keep_file_days'] = int(config['keep_file_days']) reporting_config['prev_endtime'] = config['prev_endtime'] reporting_config['deltaFields'] = config['delta_fields'] reporting_config['keep_file_days'] = int(config['keep_file_days']) reporting_config['prev_endtime'] = config['prev_endtime'] reporting_config['deltaFields'] = config['delta_fields'] return reporting_config
Example #6
Source File: __init__.py From script.tvguide.fullscreen with GNU General Public License v2.0 | 6 votes |
def open_resource(name): """Open a resource from the zoneinfo subdir for reading. Uses the pkg_resources module if available and no standard file found at the calculated location. """ name_parts = name.lstrip('/').split('/') for part in name_parts: if part == os.path.pardir or os.path.sep in part: raise ValueError('Bad path segment: %r' % part) filename = os.path.join(os.path.dirname(__file__), 'zoneinfo', *name_parts) if not os.path.exists(filename) and resource_stream is not None: # http://bugs.launchpad.net/bugs/383171 - we avoid using this # unless absolutely necessary to help when a broken version of # pkg_resources is installed. return resource_stream(__name__, 'zoneinfo/' + name) return open(filename, 'rb')
Example #7
Source File: addon_updater.py From coa_tools with GNU General Public License v3.0 | 6 votes |
def restore_backup(self): if self._verbose: print("Restoring backup") if self._verbose: print("Backing up current addon folder") backuploc = os.path.join(self._updater_path,"backup") tempdest = os.path.join(self._addon_root, os.pardir, self._addon+"_updater_backup_temp") tempdest = os.path.abspath(tempdest) # make the copy shutil.move(backuploc,tempdest) shutil.rmtree(self._addon_root) os.rename(tempdest,self._addon_root) self._json["backup_date"] = "" self._json["just_restored"] = True self._json["just_updated"] = True self.save_updater_json() self.reload_addon()
Example #8
Source File: addon_updater.py From coa_tools with GNU General Public License v3.0 | 6 votes |
def create_backup(self): if self._verbose: print("Backing up current addon folder") local = os.path.join(self._updater_path,"backup") tempdest = os.path.join(self._addon_root, os.pardir, self._addon+"_updater_backup_temp") if os.path.isdir(local) == True: shutil.rmtree(local) if self._verbose: print("Backup destination path: ",local) # make the copy if self._backup_ignore_patterns != None: shutil.copytree( self._addon_root,tempdest, ignore=shutil.ignore_patterns(*self._backup_ignore_patterns)) else: shutil.copytree(self._addon_root,tempdest) shutil.move(tempdest,local) # save the date for future ref now = datetime.now() self._json["backup_date"] = "{m}-{d}-{yr}".format( m=now.strftime("%B"),d=now.day,yr=now.year) self.save_updater_json()
Example #9
Source File: vscoscrape.py From vsco-scraper with MIT License | 6 votes |
def getJournal(self): self.getJournalList() self.pbarj = tqdm(total=self.totalj, desc='Downloading journal posts of %s'%self.username, unit=' posts') for x in self.works: path = os.path.join(os.getcwd(), x[0]) if not os.path.exists(path): os.makedirs(path) os.chdir(path) x.pop(0) with ThreadPoolExecutor(max_workers=5) as executor: future_to_url = {executor.submit(self.download_img_journal,part):part for part in x} for future in concurrent.futures.as_completed(future_to_url): part = future_to_url[future] try: data=future.result() except Exception as exc: print('%r crashed %s' % (part,exc)) os.chdir(os.path.normpath(os.getcwd() + os.sep + os.pardir)) self.pbarj.close()
Example #10
Source File: problem.py From EulerPy with MIT License | 6 votes |
def copy_resources(self): """Copies the relevant resources to a resources subdirectory""" if not os.path.isdir('resources'): os.mkdir('resources') resource_dir = os.path.join(os.getcwd(), 'resources', '') copied_resources = [] for resource in self.resources: src = os.path.join(EULER_DATA, 'resources', resource) if os.path.isfile(src): shutil.copy(src, resource_dir) copied_resources.append(resource) if copied_resources: copied = ', '.join(copied_resources) path = os.path.relpath(resource_dir, os.pardir) msg = "Copied {} to {}.".format(copied, path) click.secho(msg, fg='green')
Example #11
Source File: gnu.py From recruit with Apache License 2.0 | 6 votes |
def get_library_dirs(self): opt = GnuFCompiler.get_library_dirs(self) if sys.platform == 'win32': c_compiler = self.c_compiler if c_compiler and c_compiler.compiler_type == "msvc": target = self.get_target() if target: d = os.path.normpath(self.get_libgcc_dir()) root = os.path.join(d, *((os.pardir, ) * 4)) path = os.path.join(root, "lib") mingwdir = os.path.normpath(path) if os.path.exists(os.path.join(mingwdir, "libmingwex.a")): opt.append(mingwdir) # For Macports / Linux, libgfortran and libgcc are not co-located lib_gfortran_dir = self.get_libgfortran_dir() if lib_gfortran_dir: opt.append(lib_gfortran_dir) return opt
Example #12
Source File: decoding.py From fine-lm with MIT License | 6 votes |
def run_postdecode_hooks(decode_hook_args): """Run hooks after decodes have run.""" hooks = decode_hook_args.problem.decode_hooks if not hooks: return global_step = latest_checkpoint_step(decode_hook_args.estimator.model_dir) if global_step is None: tf.logging.info( "Skipping decode hooks because no checkpoint yet available.") return tf.logging.info("Running decode hooks.") parent_dir = os.path.join(decode_hook_args.output_dirs[0], os.pardir) final_dir = os.path.join(parent_dir, "decode") summary_writer = tf.summary.FileWriter(final_dir) for hook in hooks: # Isolate each hook in case it creates TF ops with tf.Graph().as_default(): summaries = hook(decode_hook_args) if summaries: summary = tf.Summary(value=list(summaries)) summary_writer.add_summary(summary, global_step) summary_writer.close() tf.logging.info("Decode hooks done.")
Example #13
Source File: paths.py From iAI with MIT License | 6 votes |
def __init__(self): self._SAMPLE_ROOT = os.path.join( os.path.dirname(os.path.abspath(__file__)), os.pardir ) self._FLATTEN_CONCAT_PLUGIN_PATH = os.path.join( self._SAMPLE_ROOT, 'build', 'libflattenconcat.so' ) self._WORKSPACE_DIR_PATH = os.path.join( self._SAMPLE_ROOT, 'workspace' ) self._VOC_DIR_PATH = \ os.path.join(self._SAMPLE_ROOT, 'VOCdevkit', 'VOC2007') # User configurable paths
Example #14
Source File: gnu.py From recruit with Apache License 2.0 | 6 votes |
def get_library_dirs(self): opt = [] if sys.platform[:5] != 'linux': d = self.get_libgcc_dir() if d: # if windows and not cygwin, libg2c lies in a different folder if sys.platform == 'win32' and not d.startswith('/usr/lib'): d = os.path.normpath(d) path = os.path.join(d, "lib%s.a" % self.g2c) if not os.path.exists(path): root = os.path.join(d, *((os.pardir, ) * 4)) d2 = os.path.abspath(os.path.join(root, 'lib')) path = os.path.join(d2, "lib%s.a" % self.g2c) if os.path.exists(path): opt.append(d2) opt.append(d) # For Macports / Linux, libgfortran and libgcc are not co-located lib_gfortran_dir = self.get_libgfortran_dir() if lib_gfortran_dir: opt.append(lib_gfortran_dir) return opt
Example #15
Source File: paths.py From iAI with MIT License | 6 votes |
def __init__(self): self._SAMPLE_ROOT = os.path.join( os.path.dirname(os.path.abspath(__file__)), os.pardir ) self._FLATTEN_CONCAT_PLUGIN_PATH = os.path.join( self._SAMPLE_ROOT, 'build', 'libflattenconcat.so' ) self._WORKSPACE_DIR_PATH = os.path.join( self._SAMPLE_ROOT, 'workspace' ) self._VOC_DIR_PATH = \ os.path.join(self._SAMPLE_ROOT, 'VOCdevkit', 'VOC2007') # User configurable paths
Example #16
Source File: test_device_configuration.py From moler with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_can_select_neighbour_devices_loaded_from_config_file_(moler_config, device_factory): conn_config = os.path.join(os.path.dirname(__file__), os.pardir, "resources", "device_config.yml") moler_config.load_config(config=conn_config, config_type='yaml') device_factory.create_all_devices() unix_local = device_factory.get_device(name='UNIX_LOCAL', establish_connection=False) import moler.device.scpi import moler.device.unixlocal neighbours = unix_local.get_neighbour_devices(device_type=moler.device.scpi.Scpi) assert 1 == len(neighbours) assert isinstance(neighbours[0], moler.device.scpi.Scpi) assert unix_local in neighbours[0].get_neighbour_devices(device_type=None) assert unix_local in neighbours[0].get_neighbour_devices(device_type=moler.device.unixlocal.UnixLocal) assert unix_local in device_factory.get_devices_by_type(device_type=None) assert unix_local in device_factory.get_devices_by_type(device_type=moler.device.unixlocal.UnixLocal) unix_local.goto_state(state=unix_local.initial_state)
Example #17
Source File: test_device_configuration.py From moler with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_can_clone_device_via_yaml(moler_config, device_factory): conn_config = os.path.join(os.path.dirname(__file__), os.pardir, "resources", "device_config.yml") moler_config.load_config(config=conn_config, config_type='yaml') device_org_name = 'UNIX_LOCAL' device_cloned_name = 'UNIX_LOCAL_CLONED_VIA_YAML' device_org = device_factory.get_device(name=device_org_name) assert device_org is not None device_cloned = device_factory.get_device(name=device_cloned_name) assert device_cloned is not None assert type(device_org) is type(device_cloned) assert device_org != device_cloned assert device_org.io_connection != device_cloned.io_connection assert device_org.io_connection.moler_connection != device_cloned.io_connection.moler_connection assert device_org.io_connection.name != device_cloned.io_connection.name device_cached_cloned = device_factory.get_cloned_device(source_device=device_org, new_name=device_cloned_name) assert device_cloned == device_cached_cloned
Example #18
Source File: test_device_configuration.py From moler with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_can_clone_device_via_name(moler_config, device_factory): conn_config = os.path.join(os.path.dirname(__file__), os.pardir, "resources", "device_config.yml") moler_config.load_config(config=conn_config, config_type='yaml') device_org_name = 'UNIX_LOCAL' device_cloned_name = 'CLONED_UNIX_LOCAL2' device_org = device_factory.get_device(name=device_org_name) assert device_org is not None device_cloned = device_factory.get_cloned_device(source_device=device_org_name, new_name=device_cloned_name) assert device_cloned is not None assert device_org != device_cloned assert device_org.io_connection != device_cloned.io_connection assert device_org.io_connection.moler_connection != device_cloned.io_connection.moler_connection assert device_org.io_connection.name != device_cloned.io_connection.name device_cached_cloned = device_factory.get_cloned_device(source_device=device_org, new_name=device_cloned_name) assert device_cloned == device_cached_cloned device_cached_cloned.goto_state('UNIX_LOCAL')
Example #19
Source File: test_device_configuration.py From moler with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_clone_device_from_cloned_device(moler_config, device_factory): conn_config = os.path.join(os.path.dirname(__file__), os.pardir, "resources", "device_config.yml") moler_config.load_config(config=conn_config, config_type='yaml') device_org_name = 'UNIX_LOCAL' device_cloned_name = 'UNIX_LOCAL_CLONED' device_recloned_name = 'UNIX_LOCAL_RECLONED' device_org = device_factory.get_device(name=device_org_name) assert device_org is not None device_cloned = device_factory.get_cloned_device(source_device=device_org, new_name=device_cloned_name) device_recloned = device_factory.get_cloned_device(source_device=device_cloned, new_name=device_recloned_name) assert device_cloned != device_recloned assert device_cloned != device_org assert device_recloned != device_org device_cloned.remove() device_recloned.remove() with pytest.raises(KeyError): device_factory.get_device(name=device_cloned_name) with pytest.raises(KeyError): device_factory.get_device(name=device_recloned_name) with pytest.raises(KeyError): # Cannot clone forgotten device. device_factory.get_cloned_device(source_device=device_cloned_name, new_name=device_recloned_name) with pytest.raises(KeyError): # Cannot clone even passed reference to forgotten device. device_factory.get_cloned_device(source_device=device_cloned, new_name=device_recloned_name)
Example #20
Source File: test_device_configuration.py From moler with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_can_clone_device(moler_config, device_factory): conn_config = os.path.join(os.path.dirname(__file__), os.pardir, "resources", "device_config.yml") moler_config.load_config(config=conn_config, config_type='yaml') device_org_name = 'UNIX_LOCAL' device_cloned_name = 'CLONED_UNIX_LOCAL1' device_org = device_factory.get_device(name=device_org_name) assert device_org is not None device_cloned = device_factory.get_cloned_device(source_device=device_org, new_name=device_cloned_name) assert device_cloned is not None assert device_org != device_cloned assert device_org.io_connection != device_cloned.io_connection assert device_org.io_connection.moler_connection != device_cloned.io_connection.moler_connection assert device_org.io_connection.name != device_cloned.io_connection.name device_cached_cloned = device_factory.get_cloned_device(source_device=device_org, new_name=device_cloned_name) assert device_cloned == device_cached_cloned device_cached_cloned.goto_state('UNIX_LOCAL')
Example #21
Source File: test_device_configuration.py From moler with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_can_select_device_loaded_from_config_file(moler_config, device_factory): conn_config = os.path.join(os.path.dirname(__file__), os.pardir, "resources", "device_config.yml") add_conn_config = os.path.join(os.path.dirname(__file__), os.pardir, "resources", "added_device_config.yml") moler_config.load_config(config=conn_config, config_type='yaml') moler_config.load_config(config=add_conn_config, config_type='yaml') device = device_factory.get_device(name='UNIX_LOCAL') added_device = device_factory.get_device(name='ADDED_UNIX_LOCAL') for device in (device, added_device): assert device.__module__ == 'moler.device.unixlocal' assert device.__class__.__name__ == 'UnixLocal'
Example #22
Source File: test_device_configuration.py From moler with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_close_defined_yaml_device(moler_config, device_factory): conn_config = os.path.join(os.path.dirname(__file__), os.pardir, "resources", "device_config.yml") moler_config.load_config(config=conn_config, config_type='yaml') device_org_name = 'UNIX_LOCAL' device_org = device_factory.get_device(name=device_org_name) assert device_org is not None device_org.remove() with pytest.raises(KeyError): device_factory.get_device(name=device_org_name) clear_all_cfg() moler_config.load_config(config=conn_config, config_type='yaml') device_2 = device_factory.get_device(name=device_org_name) assert device_2 != device_org
Example #23
Source File: devices_SM.py From moler with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_device(name, connection, device_output, test_file_path): dir_path = os.path.dirname(os.path.realpath(test_file_path)) load_config(os.path.join(dir_path, os.pardir, os.pardir, 'test', 'resources', 'device_config.yml')) device = DeviceFactory.get_device(name) device.io_connection = connection device.io_connection.name = device.name device.io_connection.moler_connection.name = device.name device.io_connection.remote_inject_response(device_output) device.io_connection.set_device(device) return device
Example #24
Source File: torchtext_test_case.py From decaNLP with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp(self): logging.basicConfig(format=('%(asctime)s - %(levelname)s - ' '%(name)s - %(message)s'), level=logging.INFO) # Directory where everything temporary and test-related is written self.project_root = os.path.abspath(os.path.realpath(os.path.join( os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir))) self.test_dir = tempfile.mkdtemp() self.test_ppid_dataset_path = os.path.join(self.test_dir, "test_ppid_dataset") self.test_numerical_features_dataset_path = os.path.join( self.test_dir, "test_numerical_features_dataset")
Example #25
Source File: copy_file_test.py From gransk with Apache License 2.0 | 5 votes |
def get_test_file(self, filename): path = os.path.realpath(__file__) return os.path.join( os.path.abspath(os.path.join(path, os.pardir)), 'test_data', filename)
Example #26
Source File: test_device_configuration.py From moler with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_load_config_and_load_new_devices(moler_config, device_factory): conn_config = os.path.join(os.path.dirname(__file__), os.pardir, "resources", "device_config.yml") moler_config.load_config(config=conn_config, config_type='yaml')
Example #27
Source File: test_device_configuration.py From moler with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_can_remove_device_twice(moler_config, device_factory): conn_config = os.path.join(os.path.dirname(__file__), os.pardir, "resources", "device_config.yml") moler_config.load_config(config=conn_config, config_type='yaml') device_org_name = 'UNIX_LOCAL' device_org = device_factory.get_device(name=device_org_name) assert device_org is not None device_org.remove() device_org.remove()
Example #28
Source File: run_preprocessing.py From cloudml-samples with Apache License 2.0 | 5 votes |
def main(): """Configures pipeline and spawns preprocessing job.""" args = _parse_arguments(sys.argv) config_path = os.path.abspath( os.path.join(__file__, os.pardir, 'preprocessing_config.ini')) config = _parse_config('CLOUD' if args.cloud else 'LOCAL', config_path) ml_project = args.project_id options = {'project': ml_project} if args.cloud: if not args.job_name: raise ValueError('Job name must be specified for cloud runs.') options.update({ 'job_name': args.job_name, 'num_workers': int(config.get('num_workers')), 'max_num_workers': int(config.get('max_num_workers')), 'staging_location': os.path.join(args.job_dir, 'staging'), 'temp_location': os.path.join(args.job_dir, 'tmp'), 'region': config.get('region'), 'setup_file': os.path.abspath( os.path.join(__file__, '../..', 'dataflow_setup.py')), }) pipeline_options = beam.pipeline.PipelineOptions(flags=[], **options) _set_logging(config.get('log_level')) with beam.Pipeline(config.get('runner'), options=pipeline_options) as p: preprocess.run(p, args.input_data, args.job_dir)
Example #29
Source File: test_device_configuration.py From moler with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_clone_and_remove_device(moler_config, device_factory): conn_config = os.path.join(os.path.dirname(__file__), os.pardir, "resources", "device_config.yml") moler_config.load_config(config=conn_config, config_type='yaml') device_org_name = 'UNIX_LOCAL' device_cloned_name = 'CLONED_UNIX_LOCAL_TO_FORGET' device_org = device_factory.get_device(name=device_org_name) assert device_org is not None with pytest.raises(KeyError): device_factory.get_device(name=device_cloned_name) device_cloned = device_factory.get_cloned_device(source_device=device_org, new_name=device_cloned_name) assert device_cloned is not None device_cloned.goto_state('UNIX_LOCAL') cmd_ping = device_cloned.get_cmd(cmd_name="ping", cmd_params={"destination": 'localhost', "options": "-w 3"}) cmd_ping.start() device_cloned.remove() with pytest.raises(WrongUsage) as err: cmd_ping.await_done() assert "is about to be closed" in str(err.value) with pytest.raises(KeyError): device_factory.get_device(name=device_cloned_name) # We can clone device with the same name again! device_cloned_again = device_factory.get_cloned_device(source_device=device_org, new_name=device_cloned_name) assert device_cloned != device_cloned_again device_by_alias = device_factory.get_device(name=device_cloned_again.public_name) assert device_by_alias == device_cloned_again assert device_cloned_again.name != device_cloned_name assert device_cloned_again.public_name == device_cloned_name cmd_ping = device_cloned_again.get_cmd(cmd_name="ping", cmd_params={"destination": 'localhost', "options": "-w 1"}) cmd_ping() device_factory.remove_device(name=device_cloned_name) with pytest.raises(KeyError): device_factory.get_device(name=device_cloned_name) with pytest.raises(KeyError): device_factory.remove_device(name=device_cloned_name)
Example #30
Source File: check-cocos-360.py From githubtools with MIT License | 5 votes |
def scan(path): _engine2 = [] for root, dirs, files in os.walk(path): for file in files: if file.endswith(".so"): print file fPath = os.path.join(root, file) check = check_engine(fPath) #print check for item in check: #print 'check:'+item #print _engine2.count(item) if(_engine2.count(item) == 0): #print '_engine2 add:' + item _engine2.append(item) return _engine2 # def unzip(source_filename, dest_dir): # print source_filename # with zipfile.ZipFile(source_filename) as zf: # for member in zf.infolist(): # # Path traversal defense copied from # # http://hg.python.org/cpython/file/tip/Lib/http/server.py#l789 # words = member.filename.split('/') # path = dest_dir # for word in words[:-1]: # drive, word = os.path.splitdrive(word) # head, word = os.path.split(word) # if word in (os.curdir, os.pardir, ''): continue # path = os.path.join(path, word) # zf.extract(member, path)