Skip to content

Nenuzhny Andrey #54

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

Open
wants to merge 89 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
5d63c1d
Init commit of first task
Nov 10, 2019
21e3713
Base and yahoo classes are comleted
Nov 12, 2019
ded173c
Added tut and default bots classes
Nov 12, 2019
cb1c1b6
Remade whole architecture
Nov 13, 2019
e61350b
Begin tests implementation
Nov 14, 2019
a32fcda
Cod is covered with test over 90%
Nov 15, 2019
42e239d
readme file with project description
Nov 15, 2019
d155454
Script to check code checks using pycodestyle module
Nov 15, 2019
f2606f8
First iteration is completed
Nov 15, 2019
1b4df02
gitignore update after merging into remote repo
Nov 16, 2019
c3fb53a
init second iteration commit - create a draft of setup.py
Nov 17, 2019
342b0c4
Rebase whole project to move rss_reader into a separete pasckage
Nov 17, 2019
c3bd27c
Fixed paths in pycodestyle.sh script and corrected README.md
Nov 17, 2019
b864ad1
Change test to tests
Nov 17, 2019
be08d70
fixed requirements.txt
Nov 17, 2019
d93137f
added a link to wheel package
Nov 17, 2019
08bf226
Added the dist directory to provide distributed packages
Nov 17, 2019
ace616e
Added the 'dist' directory to provide distributed packages
Nov 17, 2019
42f02cd
Merge branch 'master' of github.com:Nenu1985/PythonHomework
Nov 17, 2019
1d42004
Restructured news to pass mypy cheks.
Nov 18, 2019
8d8fe31
Restructured news to pass mypy cheks.
Nov 18, 2019
e184bdd
Merge pull request #1 from Nenu1985/fix/structured-news
Nenu1985 Nov 18, 2019
335b165
Merge branch 'fix/structured-news' of github.com:Nenu1985/PythonHomew…
Nov 18, 2019
59806d7
Merge branch 'fix/structured-news'
Nov 18, 2019
c78bcae
Some mypy`s annotations optimization
Nov 20, 2019
25d9379
Implement feature to store news via decorators, json and pickle
Nov 20, 2019
95ba589
Move exceptions and json patcher into another modules
Nov 20, 2019
2dcf471
Implemented feature for loading news from storage by date
Nov 20, 2019
b9f29bd
Implement SQlite3 DB to store news
Nov 21, 2019
6adcdab
Split news storage procedure into couple of methods
Nov 22, 2019
c984129
Implemented news loading from DB by input --date
Nov 23, 2019
b98fbe2
Implemented pdf converter
Nov 24, 2019
266a8ed
Add logs, converter interface, docstrings
Nov 24, 2019
62ec18c
Implemented html converter
Nov 25, 2019
9ffbb34
Fixed mypy errors
Nov 25, 2019
7ca3efa
Docstrings added to bots
Nov 25, 2019
f7cfbcc
Updated tests due to code changed. Coverd 83%
Nov 25, 2019
c0e8996
Update readme and version after merging with forth-iteration branch
Nov 26, 2019
4bfc53d
Fixed argparse error with escape symbols. Updatet dist and readme
Nov 26, 2019
578978b
fixed issue related with loading stored news and printed via tut.py bot
Nov 26, 2019
67c31d2
Added an exception when there is no news found by date
Nov 26, 2019
a3556a3
Adde python-dateutil to requerements and setup py to correct load fro…
Nov 26, 2019
dcdd116
Fixed setup
Nov 26, 2019
583c72e
Changed verison of python-dateutil package
Nov 26, 2019
8d6d84c
Update setup
Nov 26, 2019
3913528
Update setup
Nov 26, 2019
dbfa52c
`Update setup
Nov 26, 2019
674f027
`Update setup
Nov 26, 2019
8cbbdd4
Make changes in readme related to launching utility
Nov 28, 2019
45a2d3e
Merge branch 'master' of github.com:Nenu1985/PythonHomework
Nov 28, 2019
94e3ca7
Merge branch 'master' of github.com:Nenu1985/PythonHomework
Nov 28, 2019
63c96fe
Merge branch 'master' of github.com:Nenu1985/PythonHomework
Nov 28, 2019
daa2991
Fifth iteration init
Nov 28, 2019
5edd6ba
Corol shemes, Flask server
Nov 29, 2019
f5836e6
Fixed tests and requirements
Nov 29, 2019
2373d13
Home tasks
Nov 29, 2019
b65b4ed
Forgot to delete ./dist/ - deleted
Nov 29, 2019
1671e30
Add some dependencies into requirements
Nov 29, 2019
15ae496
html templates, news generation
Nov 29, 2019
77d380a
delete *htmls from .gitignore
Nov 29, 2019
9bb41c4
six-iteration functionality comleted
Nov 30, 2019
3bf6e91
Add Colors class and color initialisation procedure
Nov 30, 2019
bddc888
Replace server dir to the root, change root dir for rss_reader
Nov 30, 2019
2378724
Tested all functionality, made some fixes
Nov 30, 2019
44a1abe
Make server as launchable package
Nov 30, 2019
3b557f5
Docker unstall updates
Dec 1, 2019
3372edd
install script update
Dec 1, 2019
3f90284
install script update
Dec 1, 2019
2bdb35b
last edits
Dec 1, 2019
1691ff5
Fix error in install.sh file
Dec 1, 2019
f2c96ca
update version in readme
Dec 1, 2019
cd955cf
extra tasks
Jun 15, 2021
4ce1088
task for NY ecommmerce team
Jul 14, 2021
b49bf09
updates
Aug 3, 2021
88ceba0
1
Aug 3, 2021
782e986
aiohttp polls example init
Aug 4, 2021
d6e9835
db creation, connection, filling sample data
Aug 4, 2021
c47d019
async request to the db
Aug 4, 2021
6358126
wiring up templates
Aug 4, 2021
844fbae
вап
Aug 4, 2021
a01bd48
Merge branch 'master' into aiohttp
Aug 5, 2021
62bcd79
Merge pull request #2 from Nenu1985/aiohttp
Nenu1985 Aug 5, 2021
6aed1c2
stone game DP
Aug 5, 2021
eac4dc9
add two linked lists
Aug 5, 2021
864b587
zigzag_conversion
Aug 5, 2021
a865257
str to int myAtoi
Aug 5, 2021
8ce91fd
longest palindrome
Aug 6, 2021
354dc43
Merge pull request #3 from Nenu1985/leetcode
Nenu1985 Aug 6, 2021
a558e17
Merge pull request #4 from Nenu1985/leetcode
Nenu1985 Aug 6, 2021
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
33 changes: 31 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ __pycache__/
.Python
build/
develop-eggs/
dist/
#dist/ Need for the final's second iteration task
downloads/
eggs/
.eggs/
Expand All @@ -35,7 +35,7 @@ MANIFEST
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
# Unit tests / coverage reports
htmlcov/
.tox/
.coverage
Expand Down Expand Up @@ -102,3 +102,32 @@ venv.bak/

# mypy
.mypy_cache/

# MAC filesystem's files
.DS_Store

# pycharm files
.idea/

# tests data files
cover/
tests/data/test.html
tests/data/help.txt
tests/data/yahoo.txt

# news storage
rss_reader/storage
*sqlite3.db

# pdf & html files
*.pdf
rss_reader/my_html.html
my_html.html
static/*.pdf
static/*.html
server/templates/here.html

# Unused files
static/dejavu_font/DejaVuSansCondensed.cw127.pkl
static/dejavu_font/DejaVuSansCondensed.pkl
rss_reader/utils/no_imagepng.png
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"env": {"DEBUG": "True"},

}
]
}
303 changes: 303 additions & 0 deletions 2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
#!/usr/local/opt/python/bin/python3.7
from functools import reduce
import functools
import operator
import os



def quotes_changer(in_str):
""" Receives a string and replaces all " symbols with ' and vise versa

>>> quotes_changer('String with double quotes: " " " "')
"String with double quotes: \' \' \' \'"

>>> quotes_changer("String with single quotes: ' ' ' '")
'String with single quotes: " " " "'
"""

ch1 = '"'
ch2 = "'"
translation_map = {ord(ch1): ch2, ord(ch2): ch1}
out_str = in_str.translate(translation_map)
# out_str = in_str.replace(ch1, temp_char).replace(ch2, ch1).replace(temp_char, ch2)

return out_str


def if_str_is_palindrome(in_str):
""" Check whether a string is a palindrome or not.

Usage of any reversing functions is prohibited

>>> if_str_is_palindrome("Able was I ere I saw Elba")
True
>>> if_str_is_palindrome("A man, a plan, a canal – Panama")
True

>>> if_str_is_palindrome("A man, a plan, a canal – Panam")
False
"""
alph_str = list(filter(str.isalnum, in_str.lower()))
return alph_str[::-1] == alph_str


def split(inp: str) -> list:
"""
Custom split function - works only for spaces

>>> split('Mama washed the window frame')
['Mama', 'washed', 'the', 'window', 'frame']
"""
out = []
j = 0
for i, ch in enumerate(inp):
if ch == ' ':
out.append(inp[j:i])
j = i + 1
else:
out.append(inp[j:])
return list(filter(None, out))


def split_by_index(s: str, indexes: list) -> list:
"""

>>> split_by_index("pythoniscool,isn'tit?", [6, 8, 12, 13, 18])
['python', 'is', 'cool', ',', "isn't", 'it?']

>>> split_by_index("no luck", [42])
['no luck']
"""
out = []
j = 0
for idx in (indexes):
out.append(s[j:idx])
j = idx
else:
out.append(s[j:])
return list(filter(None, out))


def get_digits(di: int) -> tuple:
"""
>>> get_digits(87178291199)
(8, 7, 1, 7, 8, 2, 9, 1, 1, 9, 9)
"""

return tuple(int(i) for i in str(di))


def get_longest_word(s: str) -> str:
"""
>>> get_longest_word('Python is simple and effective!')
'effective!'
>>> get_longest_word('Any pythonista like namespaces a lot.')
'pythonista'
"""
return max(s.split(' '), key=len)


def foo(integers: list):
"""
>>> foo([1, 2, 3, 4, 5])
[120, 60, 40, 30, 24]
"""
result = []
for i, num in enumerate(integers):
t = integers[:] # making a copy
t.pop(i)
result.append(functools.reduce(operator.mul, t, 1))
return result


def get_pairs(inp):
"""
>>> get_pairs([1, 2, 3, 8, 9])
[(1, 2), (2, 3), (3, 8), (8, 9)]
>>> get_pairs(['need', 'to', 'sleep', 'more'])
[('need', 'to'), ('to', 'sleep'), ('sleep', 'more')]
>>> get_pairs([1])

"""
return list(zip(inp[0::1], inp[1::1])) or None


def get_sums(inp: list):
"""
>>> get_sums([1, 2, 3, 4])
[1, 3, 6, 10]
"""
# result = []
# for idx, d in enumerate(inp):
# result.append(sum(inp[0:idx + 1]))
return [sum(inp[0:idx + 1]) for idx in range(len(inp))]


def get_target_array(inp: list, target_value: int):
"""
>>> get_target_array([1, 3, 7, 10], 11)
[0, 3]
"""

for i in inp:
if i < target_value:
pair = target_value - i
if pair in inp:
# print(f"the first number= {i} the second number {pair}")
return[inp.index(i), inp.index(pair)]
break


def get_target_array_dict(list_, target_value):
hash_table = {}
len_list = len(list_)
result = []
for item in range(len_list):
if list_[item] in hash_table:
result.extend([hash_table[list_[item]], item])
else:
hash_table[target_value - list_[item]] = item
return result


def F(n: int):
'''returns value of the n-th element of Fibonacci sequence'''
if n == 0: return 0
elif n == 1: return 1
else: return F(n-1)+F(n-2)


def fibonacci(n: int):
''' Returns the Fibonacci sequence of the length '''
r = []
for i in range(10):
r.append(F(i))
print(r)





# Python3 Program to print BFS traversal
# from a given source vertex. BFS(int s)
# traverses vertices reachable from s.
from collections import defaultdict

# This class represents a directed graph
# using adjacency list representation
class Graph:

# Constructor
def __init__(self):

# default dictionary to store graph
self.graph = defaultdict(list)

# function to add an edge to graph
def addEdge(self,u,v):
self.graph[u].append(v)

# Function to print a BFS of graph
def BFS(self, s):

# Mark all the vertices as not visited
visited = [False] * (max(self.graph) + 1)

# Create a queue for BFS
queue = []

# Mark the source node as
# visited and enqueue it
queue.append(s)
visited[s] = True

while queue:

# Dequeue a vertex from
# queue and print it
s = queue.pop(0)
print (s, end = " ")

# Get all adjacent vertices of the
# dequeued vertex s. If a adjacent
# has not been visited, then mark it
# visited and enqueue it
for i in self.graph[s]:
if visited[i] == False:
queue.append(i)
visited[i] = True


def graph_driver_program():
# Create a graph given in
# the above diagram
g = Graph()
g.addEdge(0, 1)
g.addEdge(0, 2)
g.addEdge(1, 2)
g.addEdge(2, 0)
g.addEdge(2, 3)
g.addEdge(3, 3)
print ("Following is Breadth First Traversal starting from vertex 2)")

g.BFS(2)

import csv

def test_func():
with open('orders.csv', 'r') as f:
data = f.read()
if not data:
raise ValueError('No data')

rows = data.split('\n')

json_data_list = list(csv.DictReader(rows, delimiter=','))
json_data_list
output = []

hash_keys = defaultdict(list)

for item in json_data_list:
quantity = int(item.get('quantity', 0))
to_append = {
'product_id': item.get('product_id'),
'product_price': item.get('price'),
'product_title': item.get('name')
}
for _ in range(quantity):
hash_keys[(item.get('order_id'), item.get('cust_name'))].append(to_append)

output = []
for key, value in hash_keys.items():
order_id, cust_name = key
items = value
output.append({
'oder_id': order_id,
'items': items,
'cust_name': cust_name,
})

import requests

requests.post(url='https://my.awesome-api.com/orders', data=output, headers={
'Content-Type': 'application/json'
})

return data

if __name__ == "__main__":
debug = os.environ.get('DEBUG')
if not debug:
import doctest

doctest.testmod()
else:
# split('Mama washed the window frame')
# get_sums([1, 2, 3, 4])
# fibonacci(10)
# get_target_array([1, 3, 7, 10], 11)
# bubbleSort([])
# graph_driver_program()
test_func()
Loading