Skip to content

Commit

Permalink
Improve file organization
Browse files Browse the repository at this point in the history
  • Loading branch information
mjishnu committed Jun 18, 2024
1 parent 060f573 commit dca19f0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 29 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,9 @@ The `Basicdown` class is the base downloader class that provides the basic struc

- `download(url, path, mode, session, **kwargs)`: Downloads data in chunks.

#### `Simpledown()`
#### `Singledown()`

The `Simpledown` class extends `Basicdown` and is responsible for downloading a whole file in a single segment.
The `Singledown` class extends `Basicdown` and is responsible for downloading a whole file in a single segment.

##### Methods

Expand Down
5 changes: 4 additions & 1 deletion pypdl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from .main import Pypdl, PypdlFactory
__version__ = "1.4.1"

from .pypdl_manager import Pypdl
from .pypdl_factory import PypdlFactory
2 changes: 1 addition & 1 deletion pypdl/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def download(
break


class Simpledown(Basicdown):
class Singledown(Basicdown):
"""Class for downloading the whole file in a single segment."""

async def worker(
Expand Down
18 changes: 0 additions & 18 deletions pypdl/main.py

This file was deleted.

10 changes: 8 additions & 2 deletions pypdl/factory.py → pypdl/pypdl_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from logging import Logger, getLogger
from typing import Union

from .manager import DownloadManager as Pypdl
from .pypdl_manager import Pypdl
from .utls import (
AutoShutdownFuture,
ScreenCleaner,
Expand All @@ -15,7 +15,13 @@
)


class Factory:
class PypdlFactory:
"""
A factory class for managing multiple instances of the Pypdl downloader.
This class also supports additional keyword arguments specified in the documentation.
"""

def __init__(
self,
instances: int = 2,
Expand Down
12 changes: 9 additions & 3 deletions pypdl/manager.py → pypdl/pypdl_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import aiohttp

from .downloader import Multidown, Simpledown
from .downloader import Multidown, Singledown
from .utls import (
AutoShutdownFuture,
FileValidator,
Expand All @@ -24,7 +24,13 @@
)


class DownloadManager:
class Pypdl:
"""
A multi-segment file downloader that supports progress tracking, retries, pause/resume functionality etc.
This class also supports additional keyword arguments specified in the documentation.
"""

def __init__(
self,
allow_reuse: bool = False,
Expand Down Expand Up @@ -270,7 +276,7 @@ async def _multi_segment(self, segments, segment_table):
async def _single_segment(self, url, file_path):
self.logger.debug("Single-Segment download started")
async with aiohttp.ClientSession() as session:
sd = Simpledown(self._interrupt)
sd = Singledown(self._interrupt)
self._workers.append(sd)
try:
await sd.worker(url, file_path, session, **self._kwargs)
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from setuptools import setup, find_packages

VERSION = "1.4.1"
DESCRIPTION = "A concurrent python download manager"
DESCRIPTION = "A concurrent pure python download manager"
with open("README.md", "r") as f:
LONG_DESCRIPTION = f.read()

with open("pypdl/__init__.py", "r") as f:
VERSION = f.readline().split("=")[1].strip().strip("\"'")

setup(
name="pypdl",
version=VERSION,
Expand Down

0 comments on commit dca19f0

Please sign in to comment.