Skip to content

Commit

Permalink
style: set max line length to 120
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <[email protected]>
  • Loading branch information
jfcherng committed Oct 7, 2020
1 parent 2569013 commit 1decb05
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 43 deletions.
8 changes: 2 additions & 6 deletions caac_package/Crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ def fetchAndSaveDepartmentLists(self, filepaths):
departmentApplys = []

def workerFetchPage(filepath):
content = self.fetchAndSavePage(
self.projectBaseUrl + filepath, overwrite=False, log=True
)
content = self.fetchAndSavePage(self.projectBaseUrl + filepath, overwrite=False, log=True)
links = pq(content)("a")
for link in links.items():
href = link.attr("href")
Expand Down Expand Up @@ -257,9 +255,7 @@ def getPage(self, url):
while True:
# try to get page content
try:
scraper = cloudscraper.create_scraper(
delay=None, interpreter="js2py", allow_brotli=True, debug=False
)
scraper = cloudscraper.create_scraper(delay=None, interpreter="js2py", allow_brotli=True, debug=False)

return scraper.get(url).content.decode("utf-8")
# somehow we cannot get the page content
Expand Down
8 changes: 2 additions & 6 deletions caac_package/LookupDb.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ def writeOutSieveResult(self, outputFile, lookupResult, args):

for departmentId in departmentIds:
universityId = departmentId[:3]
applieds.append(
f"{self.universityMap[universityId]}\n{self.departmentMap[departmentId]}"
)
applieds.append(f"{self.universityMap[universityId]}\n{self.departmentMap[departmentId]}")

# fmt: off
worksheet.write_row(
Expand Down Expand Up @@ -197,9 +195,7 @@ def writeOutEntranceResult(self, outputFile, lookupResult, args):

for departmentId in departmentIds:
universityId = departmentId[:3]
applieds.append(
f"{self.universityMap[universityId]}\n{self.departmentMap[departmentId]}"
)
applieds.append(f"{self.universityMap[universityId]}\n{self.departmentMap[departmentId]}")

# fmt: off
worksheet.write_row(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.black]
line-length = 100
line-length = 120
target-version = ['py38']

# regex
Expand Down
12 changes: 3 additions & 9 deletions 第一階段-篩選結果(甄選委員會)/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@
help="The year of data to be processed. (ex: 2017 or 106 is the same)",
)
parser.add_argument(
"--admissionIds",
default="",
help="Admission IDs that are going to be looked up. (separate by commas)",
"--admissionIds", default="", help="Admission IDs that are going to be looked up. (separate by commas)",
)
parser.add_argument(
"--departmentIds",
default="",
help="Department IDs that are going to be looked up. (separate by commas)",
"--departmentIds", default="", help="Department IDs that are going to be looked up. (separate by commas)",
)
parser.add_argument(
"--output",
Expand All @@ -36,9 +32,7 @@
args = parser.parse_args()

year = Year.taiwanize(args.year)
resultFilepath = (
args.output if os.path.splitext(args.output)[1].lower() == ".xlsx" else f"{args.output}.xlsx"
)
resultFilepath = args.output if os.path.splitext(args.output)[1].lower() == ".xlsx" else f"{args.output}.xlsx"
dbFilepath = ProjectConfig.getCrawledDbFile(year, "apply_sieve")

# variables
Expand Down
16 changes: 4 additions & 12 deletions 第二階段-交叉查榜/cross.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
args = parser.parse_args()

year = Year.taiwanize(args.year)
resultFilepath = (
args.output if os.path.splitext(args.output)[1].lower() == ".xlsx" else args.output + ".xlsx"
)
resultFilepath = args.output if os.path.splitext(args.output)[1].lower() == ".xlsx" else args.output + ".xlsx"

# variables
crossResults = {
Expand Down Expand Up @@ -72,9 +70,7 @@ def nthuSort(department):
if departmentId.startswith("_"):
return departmentId

universityName, departmentName = splitUniversityNameAndDepartmentName(
personResult[departmentId]["_name"]
)
universityName, departmentName = splitUniversityNameAndDepartmentName(personResult[departmentId]["_name"])

# 清華大學 be the later one
if "清華大學" in universityName:
Expand Down Expand Up @@ -211,9 +207,7 @@ async def puppetFetchCrossUrls(urls):
]

if departmentNameDispatched:
universityName, departmentName = splitUniversityNameAndDepartmentName(
departmentNameDispatched[0]
)
universityName, departmentName = splitUniversityNameAndDepartmentName(departmentNameDispatched[0])
departmentNameDispatched = f"{universityName}\n{departmentName}"
else:
departmentNameDispatched = ""
Expand All @@ -234,9 +228,7 @@ async def puppetFetchCrossUrls(urls):
if departmentId.startswith("_"):
continue

universityName, departmentName = splitUniversityNameAndDepartmentName(
personResult[departmentId]["_name"]
)
universityName, departmentName = splitUniversityNameAndDepartmentName(personResult[departmentId]["_name"])

departmentResult = personResult[departmentId]

Expand Down
12 changes: 3 additions & 9 deletions 第二階段-分發結果(甄選委員會)/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@
help="The year of data to be processed. (ex: 2017 or 106 is the same)",
)
parser.add_argument(
"--admissionIds",
default="",
help="Admission IDs that are going to be looked up. (separate by commas)",
"--admissionIds", default="", help="Admission IDs that are going to be looked up. (separate by commas)",
)
parser.add_argument(
"--departmentIds",
default="",
help="Department IDs that are going to be looked up. (separate by commas)",
"--departmentIds", default="", help="Department IDs that are going to be looked up. (separate by commas)",
)
parser.add_argument(
"--output",
Expand All @@ -36,9 +32,7 @@
args = parser.parse_args()

year = Year.taiwanize(args.year)
resultFilepath = (
args.output if os.path.splitext(args.output)[1].lower() == ".xlsx" else f"{args.output}.xlsx"
)
resultFilepath = args.output if os.path.splitext(args.output)[1].lower() == ".xlsx" else f"{args.output}.xlsx"
dbFilepath = ProjectConfig.getCrawledDbFile(year, "apply_entrance")

# variables
Expand Down

0 comments on commit 1decb05

Please sign in to comment.