def main(): inote = sys.argv[1] try: c = _get_config_handler() p = PrintHandler(c) a = ArgumentHandler(c, p, inote) f = FileHandler(c, a, p, inote) n = NetworkHandler(c, f, p) o = OSHandler(c, a, f, p) o.create_temp_replica_fs() o.upload() n.notify() except: pass finally: try: # A bit hacky, just to clean up if possible o.cleanup() except: pass print() # For interactive sessions
def initialize(): ''' This is a function that prints Hello World to the console ''' # get keys with open('keys.json') as f: data = json.load(f) print("Starting...") # inititalize TweetManager t = TweetManager(data) field_names = ['id', 'name', 'created_at', 'text', 'media_type'] data = t.get_all_tweets(src.teams.nfl, field_names) f = FileHandler(data, field_names) print("Finished")
def fromFile(self, path): file_handler = FileHandler(path) self.urls = file_handler.getFileAsList() logging.info('list of urls - \n{}'.format('\n'.join(self.urls))) # returning self for enabling method chaining return self
def main(): folder = FileHandler() folder.create_folder() folder.move_file() for file in folder.fb2_books(folder.path_input): Connection().for_main(Model(folder.path_input, file))
def setUp(self) -> None: self.path1 = 'xyz' with patch("builtins.open", mock_open(read_data="test data")) as mock_file: self.sut = FileHandler(self.path1)
def test_funnelFileFormat_file(self): file1 = StringIO("test data") sut = FileHandler(file1) assert sut.data == "test data"
def test_funnelFileFormat_path(self): with patch("builtins.open", mock_open(read_data="test data")) as mock_file: sut = FileHandler(self.path1) assert sut.data == "test data" mock_file.assert_called_with(self.path1, 'r')
def cmd_interface( source: Optional[str] = typer.Option( None, "--source", show_default=False, case_sensitive=__CASE_SENSITIVE, help="Folder ID for source directory on Google Drive", ), destination: Optional[Path] = typer.Option( None, "--dest", "--destination", exists=True, # path needs to exist writable=True, # ensures a writeable path dir_okay=True, # allows path to directory file_okay=False, # rejects path to a file resolve_path=True, # resolves complete path case_sensitive=__CASE_SENSITIVE, help="Destination directory where `strm` files will be placed", ), root_name: Optional[str] = typer.Option( None, "--root", "--rootname", case_sensitive=__CASE_SENSITIVE, help="Custom name for the source directory", ), rem_extensions: bool = typer.Option( False, "--no-ext", "--no-extensions", show_default=False, case_sensitive=__CASE_SENSITIVE, help="Remove original extensions from generated strm files", ), hide_updates: bool = typer.Option( False, "--no-updates", show_default=False, case_sensitive=__CASE_SENSITIVE, help="Disable live progress/updates", ), force: bool = typer.Option( False, "--force", "-f", show_default=True, case_sensitive=__CASE_SENSITIVE, help="Wipe out root directory (if exists) in case of a collision", ), version: bool = typer.Option( None, "--version", "-v", is_eager=True, callback=__callback_version, case_sensitive=__CASE_SENSITIVE, help="Display current app version", ), ) -> None: drive_handler = DriveHandler() # authenticate drive api with output(output_type="list", initial_len=9, interval=500) as outstream: # Replace destination directory with the current directory path if not supplied destination = destination if destination else os.getcwd() file_handler = FileHandler( destination=destination, include_extensions=not rem_extensions, live_updates=not hide_updates, outstream=outstream, ) if not source or len(source) == 0: # No source directory is provided, get the user to choose a teamdrive source = drive_handler.select_teamdrive() if not hide_updates: typer.secho( f"Walking through `{drive_handler.drive_name(source)}`\n", fg=typer.colors.GREEN, err=True, ) __check_collisions( force=force, dst=join_path( destination, root_name if root_name else drive_handler.drive_name(source), ), ) drive_handler.walk( source=source, change_dir=file_handler.switch_dir, generator=file_handler.strm_generator, orig_path=destination, custom_root=root_name, ) typer.secho( f"Completed generating strm files\nFiles generated in: {destination}", fg=typer.colors.GREEN, )