Skip to content

Commit 546cd6d

Browse files
authored
Merge pull request #6 from kirankotari/code-refactor
Code refactor
2 parents b3fd537 + e252798 commit 546cd6d

6 files changed

Lines changed: 123 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# New in 2.0
2+
3+
- Added global/local feature
4+
- Added proxy feature
5+
- Added test cases
6+
- Updating README
7+
18
# New in 1.2
29

310
- Code refactoring

README.md

Lines changed: 105 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,139 @@
1111
![GitHub pull requests](https://img.shields.io/github/issues-pr/kirankotari/weblinks)
1212

1313
- [Introduction](#introduction)
14+
- [Pre-requisites](#pre-requisites)
1415
- [Installation and Downloads](#installation-and-downloads)
15-
- [Usage](#usage)
16+
- [Commands](#commands)
17+
- [Docs](#docs)
18+
- [Bug Tracker and Support](#bug-tracker-and-support)
1619
- [License and Copyright](#license-and-copyright)
1720
- [Author and Thanks](#author-and-thanks)
1821

22+
1923
## Introduction
2024

2125
Weblinks, It get all links from a given website and we can apply filters on top of it to get desired results, when you are good you can start downloading them with `-d` flag.
2226

23-
TODO: many changes, add-ons need to update in full.!
24-
25-
In the library we are supporting plain webpages, authentication based webpages.
26-
27-
## Pre-req
27+
In the library we are supporting plain webpages, authentication based webpages, proxy, authentication on proxy, etc.
2828

29-
A system need to have curl and python
30-
31-
## Docs
29+
We also support storing the config in either local/global configuration, for best practise we suggest not to store your password, you get a prompt on runtime wher you can provide it.
3230

33-
How to use weblinks?
31+
## Pre-requisites
3432

35-
```python
33+
A system need to support **curl commands** and **python3**
3634

37-
```
3835
## Installation and Downloads
3936

40-
`pip install weblinks`
37+
```shell
38+
pip install weblinks
39+
```
4140

42-
## Usage
41+
## Commands
4342

43+
```shell
44+
weblinks --help
4445
```
45-
usage: weblinks [-h] -w WEB [-u USERNAME] [-p PASSWORD] [-e EXT] [-d] [-v]
46-
substring
47-
48-
positional arguments:
49-
substring the sub-string in the links
46+
```
47+
usage: weblinks [-h] [-w WEB] [-s SUBSTRING] [-e EXT] [-d] [-u USERNAME]
48+
[-p PASSWORD] [-g] [-l] [-v] [--proxy PROXY]
49+
[--proxy-username PROXY_USERNAME]
50+
[--proxy-password PROXY_PASSWORD] [--version]
5051
5152
optional arguments:
5253
-h, --help show this help message and exit
5354
-w WEB, --web WEB the website
55+
-s SUBSTRING, --substring SUBSTRING
56+
the sub-string in the links
57+
-e EXT, --ext EXT file extention
58+
-d, --download download links
5459
-u USERNAME, --username USERNAME
5560
web login username
5661
-p PASSWORD, --password PASSWORD
5762
web login password
58-
-e EXT, --ext EXT file extention
59-
-d, --download download links
63+
-g, --global global configuration
64+
-l, --local local configuration
6065
-v, --verbosity
66+
--proxy PROXY proxy address
67+
--proxy-username PROXY_USERNAME
68+
proxy username
69+
--proxy-password PROXY_PASSWORD
70+
proxy password
71+
--version weblinks version
72+
```
73+
74+
## Docs
75+
76+
**Weblinks usage**
77+
78+
To see current lib. version
79+
```shell
80+
weblinks --version
81+
# weblinks version: 2.0
82+
```
83+
84+
To see python file from given url
85+
```shell
86+
weblinks --web https://www.python.org/ftp/python/3.8.13/ --substring Python
87+
# INFO | 2022-07-23 16:23:33,603 | run :117 | links found
88+
# Python-3.8.13.tar.xz
89+
# Python-3.8.13.tar.xz.asc
90+
# Python-3.8.13.tgz
91+
# Python-3.8.13.tgz.asc
92+
```
93+
94+
Still wanted to filter add file extention
95+
```shell
96+
weblinks --web https://www.python.org/ftp/python/3.8.13/ --substring Python --ext .tgz
97+
# INFO | 2022-07-23 16:23:33,603 | run :117 | links found
98+
# Python-3.8.13.tgz
99+
```
100+
101+
Start download, listed links are good
102+
```shell
103+
weblinks --web https://www.python.org/ftp/python/3.8.13/ --substring Python --ext .tgz -d
104+
# INFO | 2022-07-23 16:25:34,807 | run :117 | links found
105+
# Python-3.8.13.tgz
106+
# INFO | 2022-07-23 16:25:34,807 | run :124 | start download: Python-3.8.13.tgz
107+
# INFO | 2022-07-23 16:25:34,807 | utils :58 | downloading: Python-3.8.13.tgz
108+
# INFO | 2022-07-23 16:25:36,849 | run :126 | completed: Python-3.8.13.tgz
61109
```
62110

111+
For authentication
112+
```shell
113+
weblinks --web <url> --substring <sub> --username <kirankotari> --password <xxxxxx> --ext .tgz
114+
# Note: don't add --password, it will ask dynamically
115+
```
116+
117+
For verbose add -v
118+
```shell
119+
weblinks --web <url> --substring <sub> --username <kirankotari> --ext .tgz -v
120+
```
121+
122+
To store config add --local or --global respectively
123+
```shell
124+
weblinks --local --web <url> --username <kirankotari> --ext .tgz
125+
```
126+
127+
For proxy
128+
```shell
129+
weblinks --proxy <ip>:<port> --web <url> --substring <sub>
130+
```
131+
132+
For proxy with authentication
133+
```shell
134+
weblinks --proxy <ip>:<port> --web <url> --substring <sub> --proxy-username <proxy user> --proxy-password <proxy password>
135+
```
136+
137+
Adding web authentication on top of proxy auth.
138+
```shell
139+
weblinks --proxy <ip>:<port> --web <url> --substring <sub> --proxy-username <proxy user> --proxy-password <proxy password> --username <user>
140+
```
141+
142+
## Bug Tracker and Support
143+
144+
- Please report any suggestions, bug reports, or annoyances with weblinks through the [Github bug tracker](https://github.com/kirankotari/weblinks/issues). If you're having problems with general python issues, consider searching for a solution on [Stack Overflow](https://stackoverflow.com/search?q=).
145+
- If you can't find a solution for your problem or need more help, you can [ask a question](https://stackoverflow.com/questions/ask).
146+
63147
## License and Copyright
64148

65149
- weblinks is licensed [Apache 2.0](https://opensource.org/licenses/Apache-2.0) 2022

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
from os import path
33
from io import open
44

5-
version = "1.1.5"
6-
# version = "2.0" # TODO: planning to release a major version
5+
version = "2.0"
76

87
# setup file path
98
here = path.abspath(path.dirname(__file__))

tests/test_weblinks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_weblinks_version(self):
5555
self.applyPatch
5656
run.main()
5757
out, err = self._capfd.readouterr()
58-
assert out.strip() == 'weblinks version: 1.2'
58+
assert out.strip() == 'weblinks version: 2.0'
5959
del self.args['version']
6060

6161

tests/test_weblinks_proxy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def get_inputs():
3535
return args
3636

3737

38-
# TODO: need to add proxy test cases
3938
@pytest.mark.run
4039
class TestWeblinksVersion(unittest.TestCase):
4140

weblinks/run.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
and filter them using substring, a file extentions
33
44
usage: weblinks [-h] [-w WEB] [-s SUBSTRING] [-e EXT] [-d] [-u USERNAME]
5-
[-p PASSWORD] [-g] [-l] [-v] [--version]
5+
[-p PASSWORD] [-g] [-l] [-v] [--proxy PROXY]
6+
[--proxy-username PROXY_USERNAME]
7+
[--proxy-password PROXY_PASSWORD] [--version]
68
79
optional arguments:
810
-h, --help show this help message and exit
@@ -18,6 +20,11 @@
1820
-g, --global global configuration
1921
-l, --local local configuration
2022
-v, --verbosity
23+
--proxy PROXY proxy address
24+
--proxy-username PROXY_USERNAME
25+
proxy username
26+
--proxy-password PROXY_PASSWORD
27+
proxy password
2128
--version weblinks version
2229
"""
2330

@@ -32,7 +39,7 @@
3239
from .config import Configuration
3340

3441

35-
version = "1.2"
42+
version = "2.0"
3643

3744

3845
def parser() -> argparse:

0 commit comments

Comments
 (0)