forked from USTC-Resource/USTC-Course
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct python typo for data structure
- Loading branch information
Showing
34 changed files
with
2,491 additions
and
1,805 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
language: python3 | ||
sudo: required | ||
python: | ||
- "3.6" | ||
language: python | ||
python: "3.6" | ||
|
||
notifications: | ||
email: | ||
recipients: | ||
- [email protected] | ||
on_success: change # default: change | ||
on_failure: always # default: always | ||
branches: | ||
only: | ||
- master | ||
|
||
env: | ||
# Github Pages | ||
- GH_REF: github.com/USTC-Resource/USTC-Course | ||
|
||
install: | ||
- sudo apt-get install python3 -y | ||
- sudo apt-get install python3-pip -y | ||
- sudo pip3 install markdown | ||
- sudo pip3 install pypinyin | ||
- pip install --upgrade pip | ||
- pip install flake8 markdown pypinyin | ||
|
||
script: | ||
- python3 utils/genReadme.py | ||
- python3 utils/genIndex.py | ||
- flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics | ||
- python utils/genReadme.py | ||
- python utils/genIndex.py | ||
|
||
after_script: | ||
# Build Master Repository(Coding Pages) | ||
|
@@ -31,15 +29,9 @@ after_script: | |
- git commit -m "Travis-CI Update pages with build $TRAVIS_BUILD_NUMBER" | ||
- git push -f "https://${GH_TOKEN}@${GH_REF}" master:gh-pages | ||
|
||
addons: | ||
apt: | ||
update: true | ||
|
||
branches: | ||
only: | ||
- master | ||
env: | ||
global: | ||
# Github Pages | ||
- GH_REF: github.com/USTC-Resource/USTC-Course | ||
|
||
notifications: | ||
email: | ||
recipients: | ||
- [email protected] | ||
on_success: change # default: change | ||
on_failure: always # default: always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
# coding: utf-8 | ||
import os | ||
import sys | ||
|
||
|
||
def formatSize(size): | ||
s = 'BKMGTP' | ||
ct = 0 | ||
while size>=(1<<ct): | ||
ct+=10 | ||
if ct>=10: ct-=10 | ||
return '{sz:.2f}{a}'.format(sz=size/(1<<ct),a=s[ct//10]) | ||
while size >= (1 << ct): | ||
ct += 10 | ||
if ct >= 10: ct -= 10 | ||
return '{sz:.2f}{a}'.format(sz=size / (1 << ct), a=s[ct // 10]) | ||
|
||
|
||
def getSize(path='.'): | ||
if os.path.isdir(path): | ||
gen = os.walk(path) | ||
li = [] | ||
li = [] | ||
for root, dirs, files in gen: | ||
for f in files: | ||
sz = os.path.getsize(os.path.join(root ,f)) | ||
sz = os.path.getsize(os.path.join(root, f)) | ||
li.append(sz) | ||
#li.insert(('.',sum(i[1] for i in li)),0) | ||
#size = [f'{i[0]}: {formatSize(i[1])}' for i in li] | ||
return formatSize(sum(li)) | ||
else: | ||
return formatSize(os.path.getsize(path)) | ||
|
||
|
||
if __name__ == "__main__": | ||
items = sys.argv[1:] | ||
for i in items: | ||
print('{i}: {sz}'.format(i=i,sz =getSize(i))) | ||
print('{i}: {sz}'.format(i=i, sz=getSize(i))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import os | ||
|
||
def mywalk(dire,valid=lambda x:True): | ||
|
||
def mywalk(dire, valid=lambda x: True): | ||
if not os.path.isdir(dire): | ||
raise Exception('[Error]: directory excepted') | ||
dirs = [] | ||
files = [] | ||
for i in os.listdir(dire): | ||
i = os.path.join(dire,i) | ||
i = os.path.join(dire, i) | ||
if valid(i): | ||
if os.path.isdir(i): | ||
dirs.append(i) | ||
else: | ||
files.append(i) | ||
yield dire,dirs,files | ||
yield dire, dirs, files | ||
for d in dirs: | ||
yield from mywalk(os.path.join(dire,d),valid) | ||
yield from mywalk(os.path.join(dire, d), valid) |
Oops, something went wrong.