Skip to content

Commit 59924a4

Browse files
committed
i guess, everything works now 🧟
1 parent be4c3b9 commit 59924a4

File tree

8 files changed

+35
-181
lines changed

8 files changed

+35
-181
lines changed

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,11 @@ Everything up-to-date
115115
```
116116
![image](https://user-images.githubusercontent.com/23381512/60123229-9a42a380-97a4-11e9-9da0-e38b4460933d.png)
117117

118+
## Example of Repository Generated can be found [here](https://github.com/DumbMachine/SyncBoostNoteExample).
118119

119120
TODOS:
120-
- [ ] Sorting tags:
121-
- [ ] Sort the names by tag.
122-
- [ ] Sort the names by date.
123-
- [ ] sort the names by name (alphabetically)
124-
- [ ] Delete ``*.md`` file ``*.cson`` has been deleted.
125-
- [ ] Brings in oops.
126-
- [ ] 😢😢😢 Anything other than ``INTERACTIVE`` is executed twice, dunno why pliz halp.
121+
- [ ] Order Shields inline, ( Dates in one line, tags in one, folder specific in one )
122+
127123
## Thanks to this repo:
128124
- [pycson](https://github.com/avakar/pycson)
129125
- This helped in saving me alot of time.

setup.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
packages=find_packages(exclude=["tests"]),
1414
scripts=[],
1515
description="CLI tool to help syncing BoostNote notes.",
16-
long_description="Longer Desciption",
16+
long_description="A simple CLI, created in Python, to help users to Sync their notes created in BoostNote Application with their Github Account. Along with syncing, it also creates a repo with a beautiful layout and interface to consume the notes on mobile devices.",
1717
author="Ratin Kumar",
1818
author_email="ratin.kumar.2k@gmail.com",
1919
maintainer="Ratin Kumar (@DumbMachine)",
@@ -25,15 +25,14 @@
2525
# setup_requires = ["pytest-runner"],
2626
# tests_require = ["pytest"],
2727
classifiers=[
28-
# "Development Status :: 1 - Planning",
29-
# "Development Status :: 2 - Pre-Alpha",
30-
"Development Status :: 3 - Alpha",
31-
# "Development Status :: 4 - Beta",
32-
# "Development Status :: 5 - Production/Stable",
33-
# "Development Status :: 6 - Mature",
28+
# "Development Status :: 1 - Planning",
29+
# "Development Status :: 2 - Pre-Alpha",
30+
# "Development Status :: 3 - Alpha",
31+
"Development Status :: 4 - Beta",
32+
# "Development Status :: 5 - Production/Stable",
33+
# "Development Status :: 6 - Mature",
3434
"Intended Audience :: Developers",
3535
"Intended Audience :: Information Technology",
36-
"License :: OSI Approved :: BSD License",
3736
"Operating System :: MacOS",
3837
"Operating System :: POSIX",
3938
"Operating System :: Unix",

syncboostnote/cli.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def starter(args):
8585
'''
8686
if args['sync']:
8787
sync()
88+
8889
elif args['generate']:
8990
return generate_config()
9091

@@ -120,17 +121,3 @@ def run_as_command():
120121

121122

122123
run_as_command()
123-
124-
125-
# print(
126-
# '''
127-
# _________________________________
128-
# | |
129-
# | Generation was successful |
130-
# | Below is the generated config: |
131-
# | ------------------------- |
132-
# | $ cd repo_name |
133-
# | $ python setup.py install |
134-
# ------------------------------
135-
# '''
136-
# )

syncboostnote/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def interactive():
2929
['BOOSTNOTE_PATH: ', ' ~/BoostNotes', 'BOOSTNOTE_PATH'],
3030
['SHIELDS: ', ' True', 'SHIELDS'],
3131
['SHIELDS_TYPE: ', 'for-the-badge', 'SHIELDS_TYPE'],
32-
# ["hourly", "daily", "weekly", "monthly", "onchange"]
3332
['FREQUENCY: ', 'hourly', 'FREQUENCY'],
3433
['TIME: ', '1200', 'TIME'], # 24 gour format for now
3534

syncboostnote/config.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

syncboostnote/history.json

Lines changed: 0 additions & 38 deletions
This file was deleted.

syncboostnote/test.py

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -61,73 +61,3 @@ def boostnote_notes_exist(location=os.path.join(home, 'notes')):
6161
def git_update(message='nothing'):
6262
os.system('git add -A')
6363
os.system(f"git commit -m '{message}'")
64-
65-
66-
def timely_check(config):
67-
time_check = config['TIME']
68-
frequency = config['FREQUENCY']
69-
70-
if frequency == 'onchange':
71-
raise NotImplementedError('This THING is not implemented currently')
72-
else:
73-
if datetime.now().hour == time_check:
74-
print("ITS HIGH NOON")
75-
else:
76-
if datetime.now().hour > time_check:
77-
time.sleep(
78-
(datetime.now().hour - time_check) * 360
79-
)
80-
elif datetime.now().hour < time_check:
81-
time.sleep(
82-
(datetime.now().hour - time_check + 24) * 360
83-
)
84-
# time.sleep(2)
85-
print("Has the time come yet?")
86-
87-
88-
def time_check(frequency, thyme, config):
89-
'''
90-
Waits for the time and performs:
91-
1. If user mentions time, then sleep time will be time + frequency
92-
2. If user mention time, then sleep time will be 1200 hrs + frequency
93-
'''
94-
thyme = 12
95-
while(1):
96-
97-
if frequency == 'onchange':
98-
while(1):
99-
if not get_changes():
100-
# Wait
101-
print(f'Waiting for {"2 seconds"}')
102-
time.sleep(2)
103-
# time, slep(10 * 60 * 60)
104-
else:
105-
# change occured
106-
print("Calling update_changes")
107-
update_changes()
108-
print("Calling ultimate")
109-
ultimate(config)
110-
111-
if datetime.now().hour == thyme:
112-
# check updates
113-
print(gay)
114-
pass
115-
else:
116-
print('shit', datetime.now())
117-
if frequency == 'hourly':
118-
time.sleep(1 * 360 / 100)
119-
elif frequency == 'daily':
120-
time.sleep(24 * 360 / 100)
121-
elif frequency == 'weekly':
122-
time.sleep(24 * 7 * 360 / 100)
123-
124-
125-
# time_check('onchange', '14',
126-
# {
127-
# "BOOSTNOTE_PATH": os.path.join(home, 'Boostnote'),
128-
# "SHIELDS": True,
129-
# "SHIELDS_TYPE": "for-the-badge",
130-
# "FREQUENCY": "hourly",
131-
# "TIME": 11
132-
# }
133-
# )

syncboostnote/utils.py

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def initialize(config):
3535
location=os.path.join(BOOSTNOTE_NOTES, 'syncboostnote')
3636
)
3737
create_history(BOOSTNOTE_PATH)
38+
# update_changes()
3839
ultimate(config)
3940
else:
4041
raise NotADirectoryError(
@@ -120,23 +121,16 @@ def ultimate(config):
120121
- updates the .md files, which require it.
121122
-----------------------------------------------
122123
'''
123-
# print("Searching for BOOSTNOTE_PATH", end='\r')
124-
# sys.stdout.flush()
125124
if not os.path.isfile(os.path.join(config['BOOSTNOTE_PATH'], 'history.json')):
126125

127126
# Create the History json again.
128127
create_history(config['BOOSTNOTE_PATH'])
129128
if boostnote_exists(config['BOOSTNOTE_PATH']):
130129

131130
# Creating History again, as this will track if new files have been added.
132-
# sys.stdout.flush()
133-
# print("Creating History.json file", end='\r')
134131

135132
create_history(config['BOOSTNOTE_PATH'])
136133

137-
# sys.stdout.flush()
138-
# print("Creation done!", end='\r')
139-
140134
history_json = json.load(open(os.path.join(
141135
config['BOOSTNOTE_PATH'], 'history.json'), 'r'))
142136
for file in history_json.keys():
@@ -176,7 +170,6 @@ def cson_reader(location):
176170
return data
177171
else:
178172
return 0
179-
# raise FileNotFoundError(f'The cson file at {location} was not found')
180173

181174

182175
def customshield(
@@ -212,7 +205,7 @@ def markdown_writer(things, location, shields=True,
212205
213206
'''
214207
if things:
215-
embels = ['isStarred', 'isTrashed',
208+
embels = ['isStarred', 'isTrashed', 'createdAt',
216209
'updatedAt', 'type', 'folder', 'tags']
217210
shelds = []
218211
if shields:
@@ -228,8 +221,16 @@ def markdown_writer(things, location, shields=True,
228221
key, '🗑', color='black', style=options['style']))
229222

230223
elif key == 'updatedAt':
224+
year, month, day = things[key].split(
225+
':')[0][:-3].split('-') # 2019/06/29
226+
shelds.append(customshield(
227+
"UpdatedAt".replace(" ", "%20"), f"{day}%20{month}%20{year}", color='green', style=options['style']))
228+
229+
elif key == 'createdAt':
230+
year, month, day = things[key].split(
231+
':')[0][:-3].split('-') # 2019/06/29
231232
shelds.append(customshield(
232-
key, things[key].split(':')[0][:-3].replace('-', '/'), color='green', style=options['style']))
233+
"createdAt".replace(" ", "%20"), f"{day}%20{month}%20{year}", color='green', style=options['style']))
233234

234235
elif key in ['type', 'folder']:
235236
shelds.append(customshield(
@@ -353,31 +354,21 @@ def update_changes(
353354
def create_history(
354355
location=os.path.join(home, 'Boostnote')
355356
):
356-
if os.path.isfile(
357-
os.path.join(location, 'history.json')
358-
):
359-
# FIle already exists, check for changes.
360-
update_changes()
361-
print(1)
362-
363-
else:
364-
print(3)
365-
files = {}
366-
for note in get_notes():
367-
files[note.split('/')[-1]] = {
368-
'title': cson.load(open(note, 'r'))['title'],
369-
'updated': False
370-
}
371-
json.dump(
372-
files,
373-
open(os.path.join(location, 'history.json'), 'w+')
374-
)
357+
files = {}
358+
for note in get_notes():
359+
files[note.split('/')[-1]] = {
360+
'title': cson.load(open(note, 'r'))['title'],
361+
'updated': False
362+
}
363+
json.dump(
364+
files,
365+
open(os.path.join(location, 'history.json'), 'w+')
366+
)
375367

376368

377369
def create_readme(config):
378370

379371
notes = get_notes()
380-
# data = {}
381372
file = open(os.path.join(config['BOOSTNOTE_PATH'], 'README.md'), 'w+')
382373
file.write(
383374
'''# SnycBoostNotes
@@ -408,17 +399,14 @@ def create_readme(config):
408399
)
409400
for note in get_notes():
410401
data = cson_reader(note)
411-
# data[note.split("/")[-1]] = {
412-
# 'title': cson_reader(note)['title'],
413-
# 'createdAt': cson_reader(note)['createdAt'],
414-
# 'tags': cson_reader(note)['tags'],
415-
# }
416402
# ! Generate Github link here
417403
file.write(
418404
# https://github.com/DumbMachine/SyncBoostNoteExample/blob/master/notes/syncboostnote/Stolen%20Content.md
419405
f"- [{data['title']}](https://github.com/DumbMachine/{repo_name()}/blob/master/notes/syncboostnote/{data['title'].replace(' ','%20')}.md)")
406+
if data['tags']:
407+
file.write(" {}".format(customshield(
408+
label='tags', message="%20,%20".join(data['tags']), color='purple')))
420409
file.write("\n")
421-
# return data
422410

423411
awesome = 'https://img.shields.io/badge/made--with--%E2%99%A5--by-ProjectPy-blueviolet.svg'
424412

0 commit comments

Comments
 (0)