Skip to content

Commit

Permalink
Add _indent.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Apr 13, 2023
1 parent e9301ed commit 7ba1b7f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
7 changes: 7 additions & 0 deletions gdown/_indent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# textwrap.indent for Python2
def indent(text, prefix):
def prefixed_lines():
for line in text.splitlines(True):
yield (prefix + line if line.strip() else line)

return "".join(prefixed_lines())
2 changes: 1 addition & 1 deletion gdown/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import six

from . import __version__
from ._indent import indent
from .download import download
from .download import indent
from .download_folder import MAX_NUMBER_FILES
from .download_folder import download_folder
from .exceptions import FileURLRetrievalError
Expand Down
10 changes: 1 addition & 9 deletions gdown/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,14 @@
import six
import tqdm

from ._indent import indent
from .exceptions import FileURLRetrievalError
from .parse_url import parse_url

CHUNK_SIZE = 512 * 1024 # 512KB
home = osp.expanduser("~")


# textwrap.indent for Python2
def indent(text, prefix):
def prefixed_lines():
for line in text.splitlines(True):
yield (prefix + line if line.strip() else line)

return "".join(prefixed_lines())


def get_url_from_gdrive_confirmation(contents):
url = ""
for line in contents.splitlines():
Expand Down

0 comments on commit 7ba1b7f

Please sign in to comment.