Skip to content

Commit a185094

Browse files
committedNov 3, 2019
Started to implement ProtoCommentFixer class
1 parent bb7e01c commit a185094

File tree

8 files changed

+220
-10
lines changed

8 files changed

+220
-10
lines changed
 

‎README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ A tool to turn your clean python code into a hideous mess.
77

88
A longer description of your project goes here...
99

10+
## How to run
1011

11-
## Note
12+
### Developtment
13+
14+
run `python setup.py develop` to get started on developing
1215

13-
This project has been set up using PyScaffold 3.2.2. For details and usage
14-
information on PyScaffold see https://pyscaffold.org/.

‎setup.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ description = A tool to turn your clean python code into a hideous mess.
88
author = Levi Borodenko
99
author-email = Levi.borodenko@gmail.com
1010
license = mit
11-
long-description = file: README.rst
11+
long-description = file: README.md
1212
long-description-content-type = text/x-rst; charset=UTF-8
13-
url = https://github.com/pyscaffold/pyscaffold/
13+
# url = https://github.com/pyscaffold/pyscaffold/
1414
project-urls =
1515
Documentation = https://pyscaffold.org/
1616
# Change if running only on Windows, Mac or Linux (comma-separated)

‎setup.py

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
Setup file for lancer.
44
Use setup.cfg to configure your project.
55
6-
This file was generated with PyScaffold 3.2.2.
7-
PyScaffold helps you to put up the scaffold of your new Python project.
8-
Learn more under: https://pyscaffold.org/
96
"""
107
import sys
118

‎src/lancer/data/lyrics.txt

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
DJ Tim Johnson, I want everybody to stop what they're doin' (Mr. 305)
2+
Now if you know you're with somebody
3+
You're gonna take the hotel room tonight, Make some noise (woo)
4+
Meet me at the hotel room, Meet me at the hotel room
5+
Meet me at the hotel room, Meet me at the hotel room
6+
Forget about your boyfriend And meet me at the hotel room
7+
You can bring your girlfriends And meet me at the hotel room
8+
Forget about your boyfriend And meet me at the hotel room
9+
You can bring your girlfriends And meet me at the hotel room.
10+
We at the hotel, motel, Holiday Inn, We at the hotel, motel, Holiday Inn.
11+
We at the hotel, motel, Holiday Inn, We at the hotel, motel, Holiday Inn.
12+
She like that freaky stuff, Two in the "O" and one in the eye
13+
That kinky stuff, you nasty, But I like your type
14+
And like T.I., it's whatever you like, Bring your girls, just whatever the night
15+
Your man just left, I'm the plumber tonight,
16+
I'll check yo' pipes, oh you the healthy type, Well, here goes some egg whites.
17+
Now gimme that sweet, That nasty, that Gucci stuff
18+
Let me tell you what we gon' do, Two plus two, I'm gon' undress you.
19+
Then we're gonna go three and three, You gon' undress me.
20+
Then we're gonna go four and four, We gon' freak some more, but first
21+
Forget about your boyfriend And meet me at the hotel room
22+
You can bring your girlfriends And meet me at the hotel room
23+
Forget about your boyfriend And meet me at the hotel room
24+
You can bring your girlfriends And meet me at the hotel room
25+
We at the hotel, motel, Holiday Inn, We at the hotel, motel, Holiday Inn.
26+
We at the hotel, motel, Holiday Inn, We at the hotel, motel, Holiday Inn.
27+
After party in hotel lobby, Then we off to the room like vroom
28+
Put them fingers in yo' mouth, or open up yo' blouse, And pull that g-string down south
29+
Ooh, okay shawty, one's company, Two's a crowd and three's a party
30+
Your girl ain't with it, I got somebody, In my nature, she's naughty.
31+
Now gimme that sweet, That nasty, that Gucci stuff
32+
Let me tell you what we gon' do, Two plus two, I'm gon' undress you.
33+
Then we're gonna go three and three, You gon' undress me.
34+
Then we're gonna go four and four, We gon' freak some more, but first
35+
Forget about your boyfriend And meet me at the hotel room
36+
You can bring your girlfriends And meet me at the hotel room
37+
Forget about your boyfriend And meet me at the hotel room
38+
You can bring your girlfriends And meet me at the hotel room
39+
We at the hotel, motel, Holiday Inn, We at the hotel, motel, Holiday Inn.
40+
We at the hotel, motel, Holiday Inn, We at the hotel, motel, Holiday Inn.
41+
Mujeres!... ey-oh-ey-oh-ey... Yenny... oye, que bola?
42+
Mujeres!... ey-oh-ey-oh-ey... Yaminel... oye, que bola?
43+
Mujeres!... ey-oh-ey-oh-ey... Roslyn... oye, que bola?
44+
Mujeres!... ey-oh-ey-oh-ey... Zuleyma... oye, que bola?
45+
Mujeres!... ey-oh-ey-oh-ey... Cristina... oye, que bola?
46+
Mujeres!... ey-oh-ey-oh-ey... Catolina... oye, que bola?
47+
Mujeres!... ey-oh-ey-oh-ey... Sophia... oye, que bola?
48+
Mujeres!... ay-oh-ay-oh-ay... Estefany... oye, que bola? Dale
49+
I don't play football but I've touched down everywhere
50+
(everywhere) everywhere
51+
I don't play baseball but I've hit a home run everywhere, everywhere
52+
I've been to countries and cities I can't pronounce
53+
And the places on the globe I didn't know existed
54+
In Romania she pulled me to the centre
55+
she said Pit you can have me and my sister
56+
In Lebanon yeah the women are bomb
57+
And in Greece you've guessed it the women are sweet
58+
Spinned all around the world but I ain't gon' lie
59+
there's nothing like Miami's heat
60+
Welcome to Miami where them boys used to touch tourists on a daily basis
61+
Duck charges therefore hardly caught cases
62+
This is a city full of culture and different races
63+
Where all the mami's come fully equipped at young ages
64+
With the hurricanes cause even the biggest hurricane couldn't phase us
65+
We got a dome for the Heat that put y'all to sleep
66+
and we carry hits from night till morning
67+
Like Marino strong armin' the game
68+
but I'm not retiring till I got a championship ring
69+
poppin champagne simple and plain
70+
check the map and look where we at
71+
the bottom, simple as that
72+
I'm bringing it back to the fore-front
73+
like Luke in the 2 Live Crew days
74+
he's the one that's got these mami's going two waysGod bless Uncle Al but knowin him MIA was probably engraved
75+
on the tombstone that stands over his grave to this day!
76+
HEY
77+
So if your visitin our city and your sittin pretty on duce tres
78+
or duce fours watch where you park your whip
79+
cause they will leave it sittin' on bricks awfully quick
80+
GET-GET-GET-GET-GET FREAKY
81+
Mr. Worldwide
82+
Hey baby, givin' it your all when you're dancin' on me
83+
I wanna see if you give me some more
84+
Hey baby, you can be my girl, I can be your man
85+
And we can pump this jam however you want
86+
Hey baby, pump it from the side, bend it upside down
87+
Or we can pump it from the back to the front

‎src/lancer/prototype.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from lancer.skeleton import setup_logging
2+
import logging
3+
from pathlib import Path
4+
from tokenize import tokenize, untokenize, COMMENT
5+
from random import randint
6+
7+
__author__ = "Levi Borodenko"
8+
__copyright__ = "Levi Borodenko"
9+
__license__ = "mit"
10+
11+
# setting up logger instance
12+
_logger = logging.getLogger(__name__)
13+
14+
# setting up logger format and default log level
15+
setup_logging(logging.DEBUG)
16+
17+
18+
class ProtoCommentFixer(object):
19+
"""docstring for ProtoCommentFixer"""
20+
21+
def __init__(self, file: Path = Path("./")):
22+
super(ProtoCommentFixer, self).__init__()
23+
24+
# File to be fixed
25+
self.FILE_PATH = Path(file)
26+
27+
# Path to lyric file
28+
self.LYRIC_FILE = Path("./data/lyrics.txt")
29+
30+
# Number of lyrics
31+
self.NUM_LYRICS = sum(1 for line in open(self.LYRIC_FILE))
32+
33+
# check if file is a python file
34+
if self.FILE_PATH.suffix != ".py":
35+
raise ValueError("File needs to be .py")
36+
37+
def get_lyric(self) -> str:
38+
"""Returns a random song lyric.
39+
40+
[description]
41+
"""
42+
43+
# Open lyrics file and grab a random line
44+
with open(self.LYRIC_FILE) as f:
45+
46+
random_index = randint(0, self.NUM_LYRICS)
47+
48+
lyrics = f.readlines()
49+
50+
# .rstrip to remove trailing whitespace
51+
return lyrics[random_index].rstrip()
52+
53+
54+
if __name__ == '__main__':
55+
a = ProtoCommentFixer("test.py")
56+
print(a.get_lyric())

‎src/lancer/skeleton.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def fib(n):
3939
"""
4040
assert n > 0
4141
a, b = 1, 1
42-
for i in range(n-1):
43-
a, b = b, a+b
42+
for i in range(n - 1):
43+
a, b = b, a + b
4444
return a
4545

4646

‎tests/test_prototype.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import pytest
4+
from lancer.prototype import ProtoCommentFixer as CommentFixer
5+
from pathlib import Path
6+
7+
__author__ = "Levi Borodenko"
8+
__copyright__ = "Levi Borodenko"
9+
__license__ = "mit"
10+
11+
12+
class TestCommentFixer(object):
13+
"""docstring for TestCommentFixer"""
14+
15+
# test file
16+
COMMENTS_FILE = "./test_scripts/comments.py"
17+
18+
# test instance
19+
fixer = CommentFixer(COMMENTS_FILE)
20+
21+
def test_init(self):
22+
"""Testing basic attributes.
23+
"""
24+
assert isinstance(self.fixer.FILE_PATH, Path)
25+
assert self.fixer.FILE_PATH.name == "comments.py"
26+
27+
with pytest.raises(ValueError):
28+
CommentFixer("Not_a_python_file.txt")
29+
30+
with pytest.raises(FileNotFoundError):
31+
CommentFixer("./nosuchfile.py")
32+
33+
def test_get_lyric(self):
34+
"""Test random lyric generation.
35+
"""
36+
37+
lyric = self.fixer.get_lyric()
38+
39+
assert isinstance(lyric, str)
40+
assert len(lyric) > 2
41+
42+
another_lyric = self.fixer.get_lyric()
43+
44+
assert lyric != another_lyric
45+
46+
assert self.fixer.NUM_LYRICS > 100

‎tests/test_scripts/comments.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from pathlib import Path
2+
3+
4+
def some_function(some_arg: Path= "lol"):
5+
"""[summary]
6+
7+
[description]
8+
9+
Keyword Arguments:
10+
some_arg {int} -- [description] (default: {"lol"})
11+
"""
12+
a = "b"
13+
14+
# comment 1
15+
return a
16+
17+
# comment 2
18+
19+
20+
if __name__ == '__main__':
21+
22+
# comment 3
23+
some_function()

0 commit comments

Comments
 (0)
Please sign in to comment.