Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up for pylint + flake8 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions assets/timelinecss.py
Original file line number Diff line number Diff line change
@@ -4,20 +4,20 @@
* {
box-sizing: border-box;
}

/* Set a background color */
body {
background-color: #3B4252;
font-family: Helvetica, sans-serif;
}

/* The actual timeline (the vertical ruler) */
.timeline {
position: relative;
max-width: 1200px;
margin: 0 auto;
}

/* The actual timeline (the vertical ruler) */
.timeline::after {
content: '';
@@ -29,15 +29,15 @@
left: 50%;
margin-left: -3px;
}

/* Container around content */
.container {
padding: 10px 40px;
position: relative;
background-color: inherit;
width: 50%;
}

/* The circles on the timeline */
.container::after {
content: '';
@@ -51,17 +51,17 @@
border-radius: 50%;
z-index: 1;
}

/* Place the container to the left */
.left {
left: 0;
}

/* Place the container to the right */
.right {
left: 50%;
}

/* Add arrows to the left container (pointing right) */
.left::before {
content: " ";
@@ -75,7 +75,7 @@
border-width: 10px 0 10px 10px;
border-color: transparent transparent transparent #ECEFF4;
}

/* Add arrows to the right container (pointing left) */
.right::before {
content: " ";
@@ -89,50 +89,50 @@
border-width: 10px 10px 10px 0;
border-color: transparent #ECEFF4 transparent transparent;
}

/* Fix the circle for containers on the right side */
.right::after {
left: -16px;
}

/* The actual content */
.content {
padding: 20px 30px;
background-color: #ECEFF4;
position: relative;
border-radius: 6px;
}

/* Media queries - Responsive timeline on screens less than 600px wide */
@media screen and (max-width: 600px) {
/* Place the timelime to the left */
.timeline::after {
left: 31px;
}

/* Full-width containers */
.container {
width: 100%;
padding-left: 70px;
padding-right: 25px;
}

/* Make sure that all arrows are pointing leftwards */
.container::before {
left: 60px;
border: medium solid #ECEFF4;
border-width: 10px 10px 10px 0;
border-color: transparent #ECEFF4 transparent transparent;
}

/* Make sure all circles are at the same spot */
.left::after, .right::after {
left: 15px;
}

/* Make all right containers behave like the left ones */
.right {
left: 0%;
}
}
"""
"""
6 changes: 3 additions & 3 deletions raycast/tse.py
Original file line number Diff line number Diff line change
@@ -14,11 +14,11 @@
# @raycast.author Tomasz Sobota
# @raycast.authorURL https://techbranch.net

import webbrowser
import os
import webbrowser

home_path = os.path.expanduser('~')
REPOSITORY_PATH = home_path+"/tsr"
REPOSITORY_PATH = home_path + "/tsr"

webbrowser.open('file://'+os.path.realpath(REPOSITORY_PATH))
webbrowser.open('file://' + os.path.realpath(REPOSITORY_PATH))
print("Opening")
16 changes: 8 additions & 8 deletions raycast/tsl.py
Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@
# @raycast.author Tomasz Sobota
# @raycast.authorURL https://techbranch.net

import datetime
import csv
import datetime
import os

# ------------
@@ -24,33 +24,33 @@
# modify to your preference

home_path = os.path.expanduser('~')
FILE_PATH = home_path+"/tsr/record.csv"
FILE_PATH = home_path + "/tsr/record.csv"

# ---------

current_timestamp = datetime.datetime.now()

output = f""
output = ""

# make sure directories exist
os.makedirs(os.path.dirname(FILE_PATH), exist_ok=True)

with open(FILE_PATH, "r") as csvfile:
reader = csv.reader(csvfile)
for row in reader:

if len(row) == 0:
# omit empty rows
continue

raw_datetime = row[0]
raw_tags = row[1]

parsed_datetime = datetime.datetime.fromisoformat(raw_datetime)
dt_delta = current_timestamp - parsed_datetime
dt_total_minutes = int(round(dt_delta.total_seconds()/60, 0))
dt_hours = int(dt_total_minutes/60)
dt_minutes = dt_total_minutes-dt_hours*60
dt_total_minutes = int(round(dt_delta.total_seconds() / 60, 0))
dt_hours = int(dt_total_minutes / 60)
dt_minutes = dt_total_minutes - dt_hours * 60

delta_pretty = f"{dt_hours}h {dt_minutes}m"
# that way we'll only see the last entry:
16 changes: 8 additions & 8 deletions raycast/tsn.py
Original file line number Diff line number Diff line change
@@ -16,16 +16,16 @@
# @raycast.authorURL https://techbranch.net

import datetime
import sys
import os
import sys

# ------------
# PARAMETERS
# ------------
# modify to your preference

home_path = os.path.expanduser('~')
FILE_PATH = home_path+"/tsr/notes.csv"
FILE_PATH = home_path + "/tsr/notes.csv"


# ----------------------------
@@ -35,15 +35,15 @@
notes = ""

try:
# read notes from input
notes = sys.argv[1]
# read notes from input
notes = sys.argv[1]
except IndexError:
# no notes provided
notes = "no note provided"
# no notes provided
notes = "no note provided"

if notes == "":
# if we're still seeing empty notes list
notes = "no note provided"
# if we're still seeing empty notes list
notes = "no note provided"

# ---------

16 changes: 8 additions & 8 deletions raycast/tsr.py
Original file line number Diff line number Diff line change
@@ -16,16 +16,16 @@
# @raycast.authorURL https://techbranch.net

import datetime
import sys
import os
import sys

# ------------
# PARAMETERS
# ------------
# modify to your preference

home_path = os.path.expanduser('~')
FILE_PATH = home_path+"/tsr/record.csv"
FILE_PATH = home_path + "/tsr/record.csv"


# ----------------------------
@@ -35,15 +35,15 @@
tags = ""

try:
# read tags from input
tags = sys.argv[1]
# read tags from input
tags = sys.argv[1]
except IndexError:
# no tags provided
tags = "next"
# no tags provided
tags = "next"

if tags == "":
# if we're still seeing empty tags list
tags = "next"
# if we're still seeing empty tags list
tags = "next"

# ---------

32 changes: 18 additions & 14 deletions raycast/tsv.py
Original file line number Diff line number Diff line change
@@ -14,16 +14,17 @@
# @raycast.author Tomasz Sobota
# @raycast.authorURL https://techbranch.net

import datetime
import webbrowser
import csv
import datetime
import os
import webbrowser


class RecordType:
TSR = 1
TSN = 2


class RecordSide:
LEFT = "left"
RIGHT = "right"
@@ -35,9 +36,9 @@ class RecordSide:
# modify to your preference

home_path = os.path.expanduser('~')
TSR_FILE_PATH = home_path+"/tsr/record.csv"
TSN_FILE_PATH = home_path+"/tsr/notes.csv"
HTML_OUTPUT_PATH = home_path+"/tsr/record.html"
TSR_FILE_PATH = home_path + "/tsr/record.csv"
TSN_FILE_PATH = home_path + "/tsr/notes.csv"
HTML_OUTPUT_PATH = home_path + "/tsr/record.html"

CSS_ASSETS_PATH = "../assets/timeline.css"

@@ -52,23 +53,23 @@ class RecordSide:
def get_timeline_side(record_type: RecordType):
if record_type == RecordType.TSR:
return RecordSide.LEFT
elif record_type == RecordType.TSN:
if record_type == RecordType.TSN:
return RecordSide.RIGHT
else:
return DEFAULT_ENTRY_SIDE
return DEFAULT_ENTRY_SIDE


def csv_to_timeline_entries(trows: list):
containers = []
for row in trows:

ts_side = get_timeline_side(row[2])
pretty_date = row[0].strftime('%H:%M on %d %b %Y')

html_container = f'<div class="container {ts_side}">\n<div class="content">\n'
html_container += f'<h2>{row[1]}</h2>\n'
html_container += f'<p>{pretty_date}</p>\n'
html_container += '</div>\n</div>\n'

containers.append(html_container)
# return containers as a single string with reversed order
return "".join(containers[::-1])
@@ -92,21 +93,23 @@ def generate_html_template(embedded_html: str, stylesheet: str):

<div class="timeline">
{embedded_html}
</div>
</div>

</body>
</html>"""
return html_template


def html_template_to_file(html_template: str, file_path: str):
"""Save html template to file"""
fp = file_path
if file_path == None:
if file_path is None:
fp = HTML_OUTPUT_PATH

with open(fp, "w") as f:
f.write(html_template)


def read_csv(filepath: str, recordtype: RecordType) -> list:
rows_buffer = []
with open(filepath, "r") as csvfile:
@@ -123,6 +126,7 @@ def read_csv(filepath: str, recordtype: RecordType) -> list:
rows_buffer.append([parsed_datetime, raw_data, recordtype])
return rows_buffer


def read_file_to_str(filepath):
with open(filepath, 'r') as file:
return file.read()
@@ -149,5 +153,5 @@ def read_file_to_str(filepath):
html_template = generate_html_template(html_entries, css_stylesheet)
_ = html_template_to_file(html_template, HTML_OUTPUT_PATH)

webbrowser.open('file://'+os.path.realpath(HTML_OUTPUT_PATH))
webbrowser.open('file://' + os.path.realpath(HTML_OUTPUT_PATH))
print("Compiled the html report.")