def mainbackup(args): #Init bundler object bundler = Bundler(args.source, args.destination) start = time.time() controller = ParallelMgmt(int(args.parallelism), args.source, args.destination) backup_time = time.time() return_q, elapsed = controller.start_controller(bundler) aggregate = 0.0 mib = 0 #data = {} bundled_file_arr = [] while not return_q.empty(): results = return_q.get() aggregate = aggregate + results[0] mib = mib + results[1] bundler.delete_star() end = time.time() total_elapsed_time = end-start data = metadatajson.create_obj(backup_time, bundled_file_arr) print(total_elapsed_time)
def test_complex(self): string = self.code + self.comment_block_multiline + self.code + self.comment_endline + "\n" + \ self.code + self.comment_block + self.code string_stripped = self.code + self.code + "\n" + self.code + self.code self.assertEqual( string_stripped, Bundler.strip_comments_from_js(string, self.flags_default))
def test_50(self): compressed = "" \ "<html><head><title>some title</title></head><body>\n" \ "<textare>some text that is a bit longer\n" \ "than needed and is split over multiple lines.\n" \ "so a cleanup might be needed.</textarea>\n" \ "</body></html>" self.assertEqual(Bundler.compress_html(self.string, 50), compressed)
def test_suspicious_complex(self): string = self.code + '"suspect ' + self.comment_block + '";' +\ self.code + "'suspect " + self.comment_endline + "';" +\ self.code + self.comment_block + self.comment_endline string_stripped = self.code + '"suspect ' + self.comment_block + '";' +\ self.code + "'suspect " + self.comment_endline + "';" +\ self.code self.assertEqual( string_stripped, Bundler.strip_comments_from_js(string, self.flags_default))
strip_inline_js = args.strip_inline_js.split(',') if args.strip_inline_css: strip_inline_css = args.strip_inline_css.split(',') if args.strip_inline_js_css: strip_inline_js_css = args.strip_inline_js_css.split(',') strip_inline_js.extend(strip_inline_js_css) strip_inline_css.extend(strip_inline_js_css) del strip_inline_js_css if args.outfile: outfile = open(args.outfile, 'wb') if not outfile: raise Exception('can not write output file "' + args.outfile + '"') del args ## run the bundler at the end ... bundled = Bundler(source, path, root, flags, compress_len, encoding, strip_tags, strip_inline_js, strip_inline_css).bundle() ## and write to output if hasattr(outfile, 'buffer'): # use buffer if available outfile = outfile.buffer outfile.write(bundled) outfile.close() del outfile del bundled
def test_block_middle_multiline(self): string = self.code + self.comment_block_multiline + self.code string_stripped = self.code + self.code self.assertEqual( string_stripped, Bundler.strip_comments_from_js(string, self.flags_default))
def test_block_beginning(self): string = self.comment_block + self.code string_stripped = self.code self.assertEqual( string_stripped, Bundler.strip_comments_from_js(string, self.flags_default))
def test_endline_ending(self): string = self.code + self.comment_endline string_stripped = self.code self.assertEqual( string_stripped, Bundler.strip_comments_from_js(string, self.flags_default))
def test_block_only(self): string = self.comment_block string_stripped = "" self.assertEqual( string_stripped, Bundler.strip_comments_from_js(string, self.flags_default))
def test_suspicious_endline_dq(self): string = self.code + '"' + self.comment_endline + '"' string_stripped = string self.assertEqual( string_stripped, Bundler.strip_comments_from_js(string, self.flags_default))
def strip(cls, string): return Bundler.strip_marked_line_from_css_or_js(string, cls.__stripIndicators)
def test_relative_root(self): string = "/some/path" self.assertFalse(Bundler.src_is_external(string))
def test_none(self): string = "" self.assertFalse(Bundler.src_is_external(string))
def test_absolute_no_prototol_auth(self): string = "//name:passwd@myserver" self.assertTrue(Bundler.src_is_external(string))
def test_absolute_no_prototol_port(self): string = "//myserver:1337" self.assertTrue(Bundler.src_is_external(string))
def test_absolute_no_protocol(self): string = "//myserver" self.assertTrue(Bundler.src_is_external(string))
def test_relative_suspisious(self): string = "some/path?foo://bar" self.assertFalse(Bundler.src_is_external(string))
def test_relative_double(self): string = "some//path/" self.assertFalse(Bundler.src_is_external(string))
"""Build script to create openapi.yaml from model files """ from bundler import Bundler import os bundler = Bundler( output_dir=os.path.dirname(__file__), api_files=[ './api/info.yaml', './api/api.yaml'] ) bundler.bundle()
def test_keep_first_multiline(self): string = self.comment_block_multiline + "\n" + self.code + self.comment_block_multiline + self.code string_stripped = self.comment_block_multiline + "\n" + self.code + self.code flags = self.flags_default | Bundler.FLAG_STRIP_COMMENTS_JS_KEEP_FIRST self.assertEqual(string_stripped, Bundler.strip_comments_from_js(string, flags))
def test_none(self): string = self.code string_stripped = string self.assertEqual( string_stripped, Bundler.strip_comments_from_js(string, self.flags_default))
def test_suspicious_complex(self): string = self.code + '"suspect ' + self.comment_block + '";' string_stripped = self.code + '"suspect ' + self.comment_block + '";' self.assertEqual( string_stripped, Bundler.strip_comments_from_css(string, self.flags_default))