Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhonas committed Feb 11, 2024
1 parent 681f92d commit 887c6a1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 52 deletions.
Binary file removed resume/clintp.gif
Binary file not shown.
Binary file removed resume/clintp.jpg
Binary file not shown.
65 changes: 13 additions & 52 deletions resume/examples/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,19 @@ class ExtractResume(luigi.Task):

def run(self):
pass
# Simulating JSON extraction, replace this with actual code to read JSON
# data = [
# {"id": 1, "name": "Alice"},
# {"id": 2, "name": "Bob"},
# {"id": 3, "name": "Charlie"}
# ]
# with open(self.output_file, 'w') as f:
# json.dump(data, f)

def output(self):
return luigi.LocalTarget(self.output_file)


class ConvertProfileImage(luigi.Task):
def requires(self):
return ExtractResume()
return {
'resume': ExtractResume()
}

def run(self):
resume = json.load(open(self.input().path))
resume = json.load(open(self.input()['resume'].path))
profile_image = urlopen(resume['basics']['image'])

with open('clintp.jpg', 'wb') as f:
Expand All @@ -50,62 +44,29 @@ def output(self):

class TaskA(luigi.Task):
def requires(self):
return ExtractResume()
return {
'resume': ExtractResume(),
'profile_image': ConvertProfileImage()
}

def run(self):
resume = json.load(open(self.input().path))
profile_image = urlopen(resume['basics']['image'])

# download profile image to temporary file so we can work on it
with open('clintp.jpg', 'wb') as f:
f.write(profile_image.read())

image = Image.open('clintp.jpg').quantize(
colors=256, method=2).convert('RGB')
# print(image)

# using python convert my profile_image to gif
# profile_image = Image.open(profile_image)
image_tiny = image.resize((40, 40))
# resizing the smaller image to the original size
pixelated = image_tiny.resize(image.size, Image.NEAREST)

pixelated.save('clintp.gif')
# access the resume that was generated in a previous task

resume = json.load(open(self.input()['resume'].path))
# parse the site_url and remove the protocol as it's included for some reason in the qrcode

parsed_url = urlparse(resume['basics']['url'])
url_without_protocol = parsed_url.netloc + parsed_url.path

qrcode = helpers.make_mecard(name=resume['basics']['name'],
email=(resume['basics']['email']),
url=url_without_protocol)

qrcode.to_artistic(background='clintp.gif',
qrcode.to_artistic(background=self.input()['profile_image'].path,
target=self.output().path, scale=5)

# qrcode.save(self.output().path, scale=4, background=)
# TaskA logic here
# result = json.load(open(self.input().path))
# print(result['basics']['name'])
# first_name, last_name = result["basics"]["name"].split(" ", 1)
# email = result['basics']['email']

# card = [
# 'BEGIN:VCARD',
# 'VERSION:2.1',
# f'N:{last_name};{first_name}',
# f'FN:{first_name} {last_name}',
# f'EMAIL;PREF;INTERNET:{email}',
# f'REV:1',
# 'END:VCARD'
# ]

# # write card to output
# with open(self.output().path, 'w') as f:
# f.write('\n'.join(card))

def output(self):
return luigi.LocalTarget("qrcode-clintp.gif")
return luigi.LocalTarget("clintp-qrcode.gif")


class TaskB(luigi.Task):
Expand Down
Binary file removed resume/qrcode-clintp.gif
Binary file not shown.

0 comments on commit 887c6a1

Please sign in to comment.