Skip to content

Commit

Permalink
ADD workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
asdawej committed May 22, 2024
1 parent ec62779 commit a5357ec
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 67 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: build

on: [push, pull_request]

jobs:
build:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller==6.4.0
- name: Build package
run: |
pyinstaller DesktopNote.spec
- name: Upload build artifact
uses: actions/upload-artifact@v2
with:
name: DesktopNote-build
path: |
dist/
34 changes: 34 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: format

on: [push, pull_request]

jobs:
format:

runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install autopep8
- name: Format code
run: |
autopep8 .
- name: Check code changes
run: |
git diff --exit-code
if ( $LASTEXITCODE -ne 0 )
{
exit 1
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__pycache__/
build/
dist/
*.dat
*exe
120 changes: 53 additions & 67 deletions DesktopNote.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,77 +15,71 @@ def screen(self):
for _i, _x in enumerate(TEXT):
if _i == self.y:
if TEXT[self.y] == '':
print(str(_i)+'>', '><')
print(str(_i) + '>', '><')
else:
print(
str(_i)+'>',
str(_i) + '>',
(
TEXT[self.y][:self.x]
+ '>'+TEXT[self.y][self.x]+'<'
+ TEXT[self.y][self.x+1:]
+ '>' + TEXT[self.y][self.x] + '<'
+ TEXT[self.y][self.x + 1:]
)
)
else:
print(str(_i)+'>', _x)
print(str(_i) + '>', _x)

def do_mv(self, arg):
'''Move to a location\
\n=====\
\nmv <row_order :: int> <char_order :: int>'''
'''Move to a location
mv <row_order :: int> <char_order :: int>'''
arg = [int(x) for x in arg.split()]
self.x = arg[1]
self.y = arg[0]
self.screen()

def do_r(self, arg):
'''Right move\
\n=====\
\nr <length :: int>'''
'''Right move
r <length :: int>'''
self.x += int(arg)
self.screen()

def do_l(self, arg):
'''Left move\
\n=====\
\nl <length :: int>'''
'''Left move
l <length :: int>'''
self.x -= int(arg)
self.screen()

def do_u(self, arg):
'''Up move\
\n=====\
\nu <length :: int>'''
'''Up move
u <length :: int>'''
self.y -= int(arg)
self.screen()

def do_d(self, arg):
'''Down move\
\n=====\
\nd <length :: int>'''
'''Down move
d <length :: int>'''
self.y += int(arg)
self.screen()

def do_rm(self, arg):
'''Delete a char or chars\
\n=====\
\nrm [[<row_order :: int> <char_order :: int> [<length :: int>]] | [<length>]]'''
'''Delete a char or chars
rm [[<row_order :: int> <char_order :: int> [<length :: int>]] | [<length>]]'''
arg = [int(x) for x in arg.split()]
_leng = len(arg)
# Delete string
if _leng == 0:
TEXT[self.y] = TEXT[self.y][:self.x]+TEXT[self.y][self.x+1:]
TEXT[self.y] = TEXT[self.y][:self.x] + TEXT[self.y][self.x + 1:]
elif _leng == 1:
_l = arg[0]
TEXT[self.y] = TEXT[self.y][:self.x]+TEXT[self.y][self.x+_l:]
TEXT[self.y] = TEXT[self.y][:self.x] + TEXT[self.y][self.x + _l:]
elif _leng == 2:
_x = arg[1]
_y = arg[0]
TEXT[_y] = TEXT[_y][:_x]+TEXT[_y][_x+1:]
TEXT[_y] = TEXT[_y][:_x] + TEXT[_y][_x + 1:]
elif _leng == 3:
_x = arg[1]
_y = arg[0]
_l = arg[2]
TEXT[_y] = TEXT[_y][:_x]+TEXT[_y][_x+_l:]
TEXT[_y] = TEXT[_y][:_x] + TEXT[_y][_x + _l:]
# Move pointer
if _leng == 2 or _leng == 3:
self.x = _x
Expand All @@ -95,23 +89,22 @@ def do_rm(self, arg):
if _leng_s == 0:
self.x = 0
else:
self.x = _leng_s-1
self.x = _leng_s - 1
self.screen()

def do_ad(self, arg):
'''Add a string on the right side\
\n=====\
\nad [<row_order :: int> <char_order :: int>]'''
'''Add a string on the right side
ad [<row_order :: int> <char_order :: int>]'''
arg = [int(x) for x in arg.split()]
_leng = len(arg)
# Add string
_s = input('Added string: ')
if _leng == 0:
TEXT[self.y] = TEXT[self.y][:self.x+1]+_s+TEXT[self.y][self.x+1:]
TEXT[self.y] = TEXT[self.y][:self.x + 1] + _s + TEXT[self.y][self.x + 1:]
elif _leng == 2:
_x = arg[1]
_y = arg[0]
TEXT[_y] = TEXT[_y][:_x+1]+_s+TEXT[_y][_x+1:]
TEXT[_y] = TEXT[_y][:_x + 1] + _s + TEXT[_y][_x + 1:]
# Move pointer
_leng_s = len(_s)
if _leng == 2:
Expand All @@ -121,27 +114,26 @@ def do_ad(self, arg):
self.screen()

def do_rv(self, arg): # (x, y)或无, 将一个字符修改; (x, y, l)或l, 将 l 个字符修改
'''Revise a char or chars\
\n=====\
\nrv [[<row_order :: int> <char_order :: int> [<length :: int>]] | [<length>]]'''
'''Revise a char or chars
rv [[<row_order :: int> <char_order :: int> [<length :: int>]] | [<length>]]'''
arg = [int(x) for x in arg.split()]
_leng = len(arg)
# Revise string
_s = input('New string: ')
if _leng == 0:
TEXT[self.y] = TEXT[self.y][:self.x]+_s+TEXT[self.y][self.x+1:]
TEXT[self.y] = TEXT[self.y][:self.x] + _s + TEXT[self.y][self.x + 1:]
elif _leng == 1:
_l = arg[0]
TEXT[self.y] = TEXT[self.y][:self.x]+_s+TEXT[self.y][self.x+_l:]
TEXT[self.y] = TEXT[self.y][:self.x] + _s + TEXT[self.y][self.x + _l:]
elif _leng == 2:
_x = arg[1]
_y = arg[0]
TEXT[_y] = TEXT[_y][:_x]+_s+TEXT[_y][_x+1:]
TEXT[_y] = TEXT[_y][:_x] + _s + TEXT[_y][_x + 1:]
elif _leng == 3:
_x = arg[1]
_y = arg[0]
_l = arg[2]
TEXT[_y] = TEXT[_y][:_x]+_s+TEXT[_y][_x+_l:]
TEXT[_y] = TEXT[_y][:_x] + _s + TEXT[_y][_x + _l:]
# Move pointer
_leng_s = len(_s)
if _leng == 2 or _leng == 3:
Expand All @@ -152,15 +144,14 @@ def do_rv(self, arg): # (x, y)或无, 将一个字符修改; (x, y, l)或l, 将
if _leng_ss == 0:
self.x = 0
else:
self.x = _leng_ss-1
self.x = _leng_ss - 1
else:
self.x += _leng_s-1
self.x += _leng_s - 1
self.screen()

def do_ex(self, arg):
'''Exit revising shell\
\n=====\
\nex'''
'''Exit revising shell
ex'''
return True


Expand All @@ -172,7 +163,7 @@ class Note(cmd.Cmd):
prompt = '<note>'
try:
fnote = open('note.dat', 'rb')
except:
except BaseException:
fnote = open('note.dat', 'wb')
pickle.dump([], fnote)
fnote.close()
Expand All @@ -181,30 +172,28 @@ class Note(cmd.Cmd):
fnote.close()

def do_show(self, arg):
'''Show the notes\
\n=====\
\nshow [<note_order :: int>]'''
'''Show the notes
show [<note_order :: int>]'''
os.system('cls')
print(' ==========================================================')
try:
arg = int(arg)
print('Title:', arg, self.note[arg][0])
print('Text:')
for i, s in enumerate(self.note[arg][1]):
print(str(i)+'>', s)
print(str(i) + '>', s)
print(' ==========================================================')
except:
except BaseException:
for i, x in enumerate(self.note):
print('Title:', i, x[0])
print('Text:')
for j, s in enumerate(x[1]):
print(str(j)+'>', s)
print(str(j) + '>', s)
print(' ==========================================================')

def do_write(self, arg):
'''Write a new note\
\n=====\
\nwrite'''
'''Write a new note
write'''
temp_title = input('New note title: ')
temp_text: list[str] = []
print('New note text(end with END):')
Expand All @@ -216,9 +205,8 @@ def do_write(self, arg):
self.fnote.close()

def do_revise(self, arg):
'''Revise a note\
\n=====\
\nrevise <note_order :: int>'''
'''Revise a note
revise <note_order :: int>'''
arg = int(arg)
global TEXT
TEXT = self.note[arg][1]
Expand All @@ -227,29 +215,27 @@ def do_revise(self, arg):
if x == '':
print('0>', '><')
else:
print('0>', '>'+x[0]+'<'+x[1:])
print(str(i)+'>', x)
print('0>', '>' + x[0] + '<' + x[1:])
print(str(i) + '>', x)
TextRevise().cmdloop()
self.note[arg][1] = TEXT
self.fnote = open('note.dat', 'wb')
pickle.dump(self.note, self.fnote)
self.fnote.close()

def do_delete(self, arg):
'''Delete a note\
\n=====\
\ndelete <note_order :: int>'''
'''Delete a note
delete <note_order :: int>'''
arg = int(arg)
self.note.pop(arg)
self.fnote = open('note.dat', 'wb')
pickle.dump(self.note, self.fnote)
self.fnote.close()

def do_exit(self, arg):
'''Exit DesktopNote\
\n=====\
\nexit'''
exit(0)
'''Exit DesktopNote
exit'''
return exit()

def postcmd(self, stop: bool, line: str) -> bool:
return False
Expand Down
37 changes: 37 additions & 0 deletions DesktopNote.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
['DesktopNote.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='DesktopNote',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.autopep8]
max_line_length = 120
aggressive = true
in-place = true
recursive = true

0 comments on commit a5357ec

Please sign in to comment.