Best Python code snippet using toolium_python
setup.py
Source:setup.py
...18 remove_tree(os.path.join(dirpath, dirname), verbose=self.verbose, dry_run=self.dry_run)19 for dirpath, dirnames, filenames in os.walk(tree):20 for filename in filenames:21 if any(filename.endswith(suffix) for suffix in (".so", ".dll")):22 self.__remove_file(os.path.join(dirpath, filename))23 def __remove_file(self, full_path):24 if os.path.exists(full_path):25 if not self.dry_run:26 os.unlink(full_path)27 if self.verbose >= 1:28 log.info("removing '%s'" % full_path)29 def run(self):30 _clean.run(self)31 self.__clean_tree(os.path.join(HERE, 'cyrobuf'))32 self.__clean_tree(os.path.join(HERE, 'tests'))33 tests_out = os.path.join(HERE, 'tests', 'out')34 if os.path.isdir(tests_out):35 remove_tree(tests_out, verbose=self.verbose, dry_run=self.dry_run)36 self.__remove_file(os.path.join(HERE, 'cyrobuf', 'src', CYROBUF_LIST_H))37 self.__remove_file(os.path.join(HERE, 'cyrobuf', 'src', CYROBUF_LIST_C))38 for filename in os.listdir(HERE):39 for prefix in ("cyrobuf_list", "cyrobuf_util"):40 for suffix in (".so", ".dll"):41 if filename.startswith(prefix) and filename.endswith(suffix):42 self.__remove_file(os.path.join(HERE, filename))43class PyrobufDistribution(Distribution):44 def run_commands(self):45 # By now the setup_requires deps have been fetched.46 self.cyrobufize_builtins()47 Distribution.run_commands(self)48 def cyrobufize_builtins(self):49 from jinja2 import Environment, PackageLoader50 env = Environment(loader=PackageLoader('cyrobuf.protobuf', 'templates'))51 templ_h = env.get_template('cyrobuf_list_h.tmpl')52 templ_c = env.get_template('cyrobuf_list_c.tmpl')53 listdict = {54 'cyrobuf_double_list': 'double',55 'cyrobuf_float_list': 'float',56 'cyrobuf_int_list': 'int',...
test_models.py
Source:test_models.py
...17class TestModel(unittest.TestCase):18 def __assert_model_equals__(self, m1, m2):19 self.assertEqual(type(m1), type(m2))20 self.assertSequenceEqual(m1._list_fields(), m2._list_fields())21 def __remove_file(self, path):22 if os.path.exists(path):23 shutil.rmtree(path)24 def setUp(self):25 self.pr_model = tc.pagerank.create(tc.SGraph())26 self.cc_model = tc.connected_components.create(tc.SGraph())27 self.__remove_file('~/tmp/tmp_model-%d' % temp_number)28 self.__remove_file('./tmp_model-%d' % temp_number)29 self.__remove_file('/tmp/tmp_model-%d' % temp_number)30 self.__remove_file('/tmp/tmp_model2-%d' % temp_number)31 def tearDown(self):32 self.__remove_file('~/tmp/tmp_model-%d' % temp_number)33 self.__remove_file('./tmp_model-%d' % temp_number)34 self.__remove_file('/tmp/tmp_model-%d' % temp_number)35 self.__remove_file('/tmp/tmp_model2-%d' % temp_number)36 @unittest.skip('failing since 08/30/2016')37 def test_basic_save_load(self):38 # save and load the pagerank model39 with util.TempDirectory() as tmp_pr_model_file:40 self.pr_model.save(tmp_pr_model_file)41 pr_model2 = tc.load_model(tmp_pr_model_file)42 self.__assert_model_equals__(self.pr_model, pr_model2)43 # save and load the connected_component model44 with util.TempDirectory() as tmp_cc_model_file:45 self.cc_model.save(tmp_cc_model_file)46 cc_model2 = tc.load_model(tmp_cc_model_file)47 self.__assert_model_equals__(self.cc_model, cc_model2)48 # handle different types of urls.49 # TODO: test hdfs and s3 urls....
lock.py
Source:lock.py
...10 f = open(lock_path, 'w')11 now = datetime.datetime.now()12 f.write(now.strftime("%Y-%m-%d %H:%M"))13 f.close()14 def __remove_file(self, lock_path):15 if self.__is_file_exists(lock_path):16 os.remove(lock_path)17 def lock_audio(self):18 self.__write_lock(self.__audio_lock_path)19 def lock_intro(self):20 self.__write_lock(self.__intro_lock_path)21 def unlock_audio(self):22 self.__remove_file(self.__audio_lock_path)23 def unlock_intro(self):24 self.__remove_file(self.__intro_lock_path)25 def unlock_markup(self):26 self.__remove_file(self.__markup_lock_path)27 def lock_markup(self):28 self.__write_lock(self.__markup_lock_path)29 @staticmethod30 def __is_file_exists(file_path) :31 return os.path.isfile(file_path)32 def is_audio_locked(self):33 return self.__is_file_exists(self.__audio_lock_path)34 def is_intro_locked(self):35 return self.__is_file_exists(self.__intro_lock_path)36 def is_markup_locked(self):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!