Skip to content

Commit 6484a8d

Browse files
committed
Add leetcode-export entrypoint in setup.py and rename leetcode-export to leetcode_export
1 parent bd4d5d9 commit 6484a8d

File tree

8 files changed

+40
-17
lines changed

8 files changed

+40
-17
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ docker run -it -v $(pwd):/usr/app/out --rm nevermendel/leetcode-export
4949
The script accepts the following arguments:
5050

5151
```bash
52-
usage: app.py [-h] [--username USERNAME] [--password PASSWORD]
53-
[--folder FOLDER] [--cookies COOKIES] [-v] [-vv]
54-
[--problem-filename PROBLEM_FILENAME]
55-
[--submission-filename SUBMISSION_FILENAME]
52+
usage: leetcode-export [-h] [--username USERNAME] [--password PASSWORD]
53+
[--folder FOLDER] [--cookies COOKIES] [-v] [-vv]
54+
[--problem-filename PROBLEM_FILENAME]
55+
[--submission-filename SUBMISSION_FILENAME]
5656

5757
Export LeetCode solutions
5858

@@ -84,7 +84,7 @@ To log in using username and password, insert them using the interactive menu (p
8484
lunching the script, like in the following example:
8585

8686
```bash
87-
python ./app.py --username {USERNAME} --password {PASSWORD}`
87+
python leetcode-export --username {USERNAME} --password {PASSWORD}`
8888
```
8989

9090
The former option is to be preferred as it will avoid storing your password in the command history.
@@ -95,7 +95,7 @@ To log in using cookies, pass the string containing them as arguments when lunch
9595
example:
9696

9797
```bash
98-
python ./app.py --cookies {COOKIES}
98+
python leetcode-export --cookies {COOKIES}
9999
```
100100

101101
## Filename template arguments
@@ -106,7 +106,7 @@ To change the format of the problem description filename, you can provide a temp
106106
script.
107107

108108
```bash
109-
python ./app.py --problem-filename PROBLEM_FILENAME
109+
python leetcode-export --problem-filename PROBLEM_FILENAME
110110
```
111111

112112
The template can contain parameters that will later be replaced based on the LeetCode problem information. The available
@@ -127,7 +127,7 @@ Default problem description filename template: `${questionId} - ${titleSlug}.txt
127127
To change the format of the submission filename, you can provide a template as a string when lunching the script.
128128

129129
```bash
130-
python ./app.py --submission-filename SUBMISSION_FILENAME
130+
python leetcode-export --submission-filename SUBMISSION_FILENAME
131131
```
132132

133133
The template can contain parameters that will later be replaced based on your submission information. The available

leetcode_export/__init__.py

Whitespace-only changes.

leetcode-export/app.py renamed to leetcode_export/__main__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from string import Template
77
from typing import List, Dict
88

9-
from leetcode import LeetCode
10-
from leetcode_rest import Submission
9+
from leetcode_export.leetcode import LeetCode
10+
from leetcode_export.leetcode_rest import Submission
1111

1212
PROBLEM_CONTENT_TEMPLATE = Template('''${questionId} - ${title}
1313
${difficulty} - https://leetcode.com/problems/${titleSlug}/
@@ -35,7 +35,7 @@ def parse_args():
3535
return parser.parse_args()
3636

3737

38-
class App(object):
38+
def main():
3939
args = parse_args()
4040

4141
# Set logging level based on program arguments
@@ -119,3 +119,7 @@ class App(object):
119119
logging.info(f"{slug}/{sub_filename} already exists, skipping it")
120120

121121
os.chdir("..")
122+
123+
124+
if __name__ == '__main__':
125+
main()

leetcode-export/leetcode.py renamed to leetcode_export/leetcode.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
import requests
77

8-
from leetcode_graphql import GRAPHQL_URL, question_detail_json, Problem
9-
from leetcode_rest import LOGIN_URL, SUBMISSIONS_API_URL, Submission, BASE_URL
10-
from utils import language_to_extension, remove_special_characters
8+
from leetcode_export.leetcode_graphql import GRAPHQL_URL, question_detail_json, Problem
9+
from leetcode_export.leetcode_rest import LOGIN_URL, SUBMISSIONS_API_URL, Submission, BASE_URL
10+
from leetcode_export.utils import language_to_extension, remove_special_characters
1111

1212

1313
class LeetCode(object):
File renamed without changes.
File renamed without changes.
File renamed without changes.

setup.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1-
from setuptools import setup
1+
from setuptools import setup, find_packages
2+
3+
with open("README.md", 'r') as f:
4+
long_description = f.read()
25

36
setup(
47
name='leetcode-export',
58
version='1.0',
6-
packages=['requests', 'selenium', 'dataclasses_json'],
79
url='https://github.com/NeverMendel/leetcode-export',
810
license='Apache-2.0',
911
author='Davide Cazzin',
10-
description='Python script to export your LeetCode solutions'
12+
description='Python script to export your LeetCode solutions',
13+
long_description=long_description,
14+
long_description_content_type='text/markdown',
15+
keywords=['leetcode', 'leetcode-solutios', 'leetcode-export'],
16+
classifiers=[
17+
'Programming Language :: Python :: 3',
18+
'Programming Language :: Python :: 3.8',
19+
'License :: OSI Approved :: Apache Software License 2.0 (Apache-2.0)',
20+
'Operating System :: OS Independent',
21+
],
22+
packages=find_packages(),
23+
install_requires=['dataclasses_json', 'requests'],
24+
python_requires=">=3.7",
25+
entry_points={
26+
'console_scripts': [
27+
'leetcode-export=leetcode_export.__main__:main',
28+
]
29+
}
1130
)

0 commit comments

Comments
 (0)