prompt
large_stringlengths 72
9.34k
| completion
large_stringlengths 0
7.61k
|
---|---|
<|file_name|>_isyclimate.py<|end_file_name|><|fim▁begin|>"""
This is a subfile for IsyClass.py
These funtions are accessable via the Isy class opj
"""
__author__ = 'Peter Shipley <[email protected]>'
__copyright__ = "Copyright (C) 2013 Peter Shipley"
__license__ = "BSD"
import time
##
## Climate funtions
##
def load_clim(self):
""" Load climate data from ISY device
args: none
internal function call
"""
if self.debug & 0x01:
print("load_clim")
clim_tree = self._getXMLetree("/rest/climate")
self.climateinfo = dict()
if clim_tree is None:
return
# Isy._printXML(self.climateinfo)
for cl in clim_tree.iter("climate"):
for k, v in cl.items():
self.climateinfo[k] = v
for ce in list(cl):
self.climateinfo[ce.tag] = ce.text
self.climateinfo["time"] = time.gmtime()
def clim_get_val(self, prop):
pass
def clim_query(self):
""" returns dictionary of climate info """
if not self.climateinfo:
<|fim_middle|>
#
# ADD CODE to check self.cachetime
#
return self.climateinfo
def clim_iter(self):
""" Iterate though climate values
args:
None
returns:
Return an iterator over the climate values
"""
if not self.climateinfo:
self.load_clim()
k = self.climateinfo.keys()
for p in k:
yield self.climateinfo[p]
# Do nothing
# (syntax check)
#
if __name__ == "__main__":
import __main__
print(__main__.__file__)
print("syntax ok")
exit(0)
<|fim▁end|> | self.load_clim() |
<|file_name|>_isyclimate.py<|end_file_name|><|fim▁begin|>"""
This is a subfile for IsyClass.py
These funtions are accessable via the Isy class opj
"""
__author__ = 'Peter Shipley <[email protected]>'
__copyright__ = "Copyright (C) 2013 Peter Shipley"
__license__ = "BSD"
import time
##
## Climate funtions
##
def load_clim(self):
""" Load climate data from ISY device
args: none
internal function call
"""
if self.debug & 0x01:
print("load_clim")
clim_tree = self._getXMLetree("/rest/climate")
self.climateinfo = dict()
if clim_tree is None:
return
# Isy._printXML(self.climateinfo)
for cl in clim_tree.iter("climate"):
for k, v in cl.items():
self.climateinfo[k] = v
for ce in list(cl):
self.climateinfo[ce.tag] = ce.text
self.climateinfo["time"] = time.gmtime()
def clim_get_val(self, prop):
pass
def clim_query(self):
""" returns dictionary of climate info """
if not self.climateinfo:
self.load_clim()
#
# ADD CODE to check self.cachetime
#
return self.climateinfo
def clim_iter(self):
""" Iterate though climate values
args:
None
returns:
Return an iterator over the climate values
"""
if not self.climateinfo:
<|fim_middle|>
k = self.climateinfo.keys()
for p in k:
yield self.climateinfo[p]
# Do nothing
# (syntax check)
#
if __name__ == "__main__":
import __main__
print(__main__.__file__)
print("syntax ok")
exit(0)
<|fim▁end|> | self.load_clim() |
<|file_name|>_isyclimate.py<|end_file_name|><|fim▁begin|>"""
This is a subfile for IsyClass.py
These funtions are accessable via the Isy class opj
"""
__author__ = 'Peter Shipley <[email protected]>'
__copyright__ = "Copyright (C) 2013 Peter Shipley"
__license__ = "BSD"
import time
##
## Climate funtions
##
def load_clim(self):
""" Load climate data from ISY device
args: none
internal function call
"""
if self.debug & 0x01:
print("load_clim")
clim_tree = self._getXMLetree("/rest/climate")
self.climateinfo = dict()
if clim_tree is None:
return
# Isy._printXML(self.climateinfo)
for cl in clim_tree.iter("climate"):
for k, v in cl.items():
self.climateinfo[k] = v
for ce in list(cl):
self.climateinfo[ce.tag] = ce.text
self.climateinfo["time"] = time.gmtime()
def clim_get_val(self, prop):
pass
def clim_query(self):
""" returns dictionary of climate info """
if not self.climateinfo:
self.load_clim()
#
# ADD CODE to check self.cachetime
#
return self.climateinfo
def clim_iter(self):
""" Iterate though climate values
args:
None
returns:
Return an iterator over the climate values
"""
if not self.climateinfo:
self.load_clim()
k = self.climateinfo.keys()
for p in k:
yield self.climateinfo[p]
# Do nothing
# (syntax check)
#
if __name__ == "__main__":
<|fim_middle|>
<|fim▁end|> | import __main__
print(__main__.__file__)
print("syntax ok")
exit(0) |
<|file_name|>_isyclimate.py<|end_file_name|><|fim▁begin|>"""
This is a subfile for IsyClass.py
These funtions are accessable via the Isy class opj
"""
__author__ = 'Peter Shipley <[email protected]>'
__copyright__ = "Copyright (C) 2013 Peter Shipley"
__license__ = "BSD"
import time
##
## Climate funtions
##
def <|fim_middle|>(self):
""" Load climate data from ISY device
args: none
internal function call
"""
if self.debug & 0x01:
print("load_clim")
clim_tree = self._getXMLetree("/rest/climate")
self.climateinfo = dict()
if clim_tree is None:
return
# Isy._printXML(self.climateinfo)
for cl in clim_tree.iter("climate"):
for k, v in cl.items():
self.climateinfo[k] = v
for ce in list(cl):
self.climateinfo[ce.tag] = ce.text
self.climateinfo["time"] = time.gmtime()
def clim_get_val(self, prop):
pass
def clim_query(self):
""" returns dictionary of climate info """
if not self.climateinfo:
self.load_clim()
#
# ADD CODE to check self.cachetime
#
return self.climateinfo
def clim_iter(self):
""" Iterate though climate values
args:
None
returns:
Return an iterator over the climate values
"""
if not self.climateinfo:
self.load_clim()
k = self.climateinfo.keys()
for p in k:
yield self.climateinfo[p]
# Do nothing
# (syntax check)
#
if __name__ == "__main__":
import __main__
print(__main__.__file__)
print("syntax ok")
exit(0)
<|fim▁end|> | load_clim |
<|file_name|>_isyclimate.py<|end_file_name|><|fim▁begin|>"""
This is a subfile for IsyClass.py
These funtions are accessable via the Isy class opj
"""
__author__ = 'Peter Shipley <[email protected]>'
__copyright__ = "Copyright (C) 2013 Peter Shipley"
__license__ = "BSD"
import time
##
## Climate funtions
##
def load_clim(self):
""" Load climate data from ISY device
args: none
internal function call
"""
if self.debug & 0x01:
print("load_clim")
clim_tree = self._getXMLetree("/rest/climate")
self.climateinfo = dict()
if clim_tree is None:
return
# Isy._printXML(self.climateinfo)
for cl in clim_tree.iter("climate"):
for k, v in cl.items():
self.climateinfo[k] = v
for ce in list(cl):
self.climateinfo[ce.tag] = ce.text
self.climateinfo["time"] = time.gmtime()
def <|fim_middle|>(self, prop):
pass
def clim_query(self):
""" returns dictionary of climate info """
if not self.climateinfo:
self.load_clim()
#
# ADD CODE to check self.cachetime
#
return self.climateinfo
def clim_iter(self):
""" Iterate though climate values
args:
None
returns:
Return an iterator over the climate values
"""
if not self.climateinfo:
self.load_clim()
k = self.climateinfo.keys()
for p in k:
yield self.climateinfo[p]
# Do nothing
# (syntax check)
#
if __name__ == "__main__":
import __main__
print(__main__.__file__)
print("syntax ok")
exit(0)
<|fim▁end|> | clim_get_val |
<|file_name|>_isyclimate.py<|end_file_name|><|fim▁begin|>"""
This is a subfile for IsyClass.py
These funtions are accessable via the Isy class opj
"""
__author__ = 'Peter Shipley <[email protected]>'
__copyright__ = "Copyright (C) 2013 Peter Shipley"
__license__ = "BSD"
import time
##
## Climate funtions
##
def load_clim(self):
""" Load climate data from ISY device
args: none
internal function call
"""
if self.debug & 0x01:
print("load_clim")
clim_tree = self._getXMLetree("/rest/climate")
self.climateinfo = dict()
if clim_tree is None:
return
# Isy._printXML(self.climateinfo)
for cl in clim_tree.iter("climate"):
for k, v in cl.items():
self.climateinfo[k] = v
for ce in list(cl):
self.climateinfo[ce.tag] = ce.text
self.climateinfo["time"] = time.gmtime()
def clim_get_val(self, prop):
pass
def <|fim_middle|>(self):
""" returns dictionary of climate info """
if not self.climateinfo:
self.load_clim()
#
# ADD CODE to check self.cachetime
#
return self.climateinfo
def clim_iter(self):
""" Iterate though climate values
args:
None
returns:
Return an iterator over the climate values
"""
if not self.climateinfo:
self.load_clim()
k = self.climateinfo.keys()
for p in k:
yield self.climateinfo[p]
# Do nothing
# (syntax check)
#
if __name__ == "__main__":
import __main__
print(__main__.__file__)
print("syntax ok")
exit(0)
<|fim▁end|> | clim_query |
<|file_name|>_isyclimate.py<|end_file_name|><|fim▁begin|>"""
This is a subfile for IsyClass.py
These funtions are accessable via the Isy class opj
"""
__author__ = 'Peter Shipley <[email protected]>'
__copyright__ = "Copyright (C) 2013 Peter Shipley"
__license__ = "BSD"
import time
##
## Climate funtions
##
def load_clim(self):
""" Load climate data from ISY device
args: none
internal function call
"""
if self.debug & 0x01:
print("load_clim")
clim_tree = self._getXMLetree("/rest/climate")
self.climateinfo = dict()
if clim_tree is None:
return
# Isy._printXML(self.climateinfo)
for cl in clim_tree.iter("climate"):
for k, v in cl.items():
self.climateinfo[k] = v
for ce in list(cl):
self.climateinfo[ce.tag] = ce.text
self.climateinfo["time"] = time.gmtime()
def clim_get_val(self, prop):
pass
def clim_query(self):
""" returns dictionary of climate info """
if not self.climateinfo:
self.load_clim()
#
# ADD CODE to check self.cachetime
#
return self.climateinfo
def <|fim_middle|>(self):
""" Iterate though climate values
args:
None
returns:
Return an iterator over the climate values
"""
if not self.climateinfo:
self.load_clim()
k = self.climateinfo.keys()
for p in k:
yield self.climateinfo[p]
# Do nothing
# (syntax check)
#
if __name__ == "__main__":
import __main__
print(__main__.__file__)
print("syntax ok")
exit(0)
<|fim▁end|> | clim_iter |
<|file_name|>leetcode.125.valid-palindrome.py<|end_file_name|><|fim▁begin|><|fim▁hole|> :type s: str
:rtype: bool
"""
if not s:
return True
start = 0
end = len(s)-1
s = s.lower()
while start < end:
while start < end and not s[start].isalnum():
start += 1
while start < end and not s[end].isalnum():
end -= 1
if s[start] == s[end]:
start += 1
end -= 1
else:
return False
return True<|fim▁end|> | class Solution(object):
def isPalindrome(self, s):
""" |
<|file_name|>leetcode.125.valid-palindrome.py<|end_file_name|><|fim▁begin|>class Solution(object):
<|fim_middle|>
<|fim▁end|> | def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
if not s:
return True
start = 0
end = len(s)-1
s = s.lower()
while start < end:
while start < end and not s[start].isalnum():
start += 1
while start < end and not s[end].isalnum():
end -= 1
if s[start] == s[end]:
start += 1
end -= 1
else:
return False
return True |
<|file_name|>leetcode.125.valid-palindrome.py<|end_file_name|><|fim▁begin|>class Solution(object):
def isPalindrome(self, s):
<|fim_middle|>
<|fim▁end|> | """
:type s: str
:rtype: bool
"""
if not s:
return True
start = 0
end = len(s)-1
s = s.lower()
while start < end:
while start < end and not s[start].isalnum():
start += 1
while start < end and not s[end].isalnum():
end -= 1
if s[start] == s[end]:
start += 1
end -= 1
else:
return False
return True |
<|file_name|>leetcode.125.valid-palindrome.py<|end_file_name|><|fim▁begin|>class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
if not s:
<|fim_middle|>
start = 0
end = len(s)-1
s = s.lower()
while start < end:
while start < end and not s[start].isalnum():
start += 1
while start < end and not s[end].isalnum():
end -= 1
if s[start] == s[end]:
start += 1
end -= 1
else:
return False
return True<|fim▁end|> | return True |
<|file_name|>leetcode.125.valid-palindrome.py<|end_file_name|><|fim▁begin|>class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
if not s:
return True
start = 0
end = len(s)-1
s = s.lower()
while start < end:
while start < end and not s[start].isalnum():
start += 1
while start < end and not s[end].isalnum():
end -= 1
if s[start] == s[end]:
<|fim_middle|>
else:
return False
return True<|fim▁end|> | start += 1
end -= 1 |
<|file_name|>leetcode.125.valid-palindrome.py<|end_file_name|><|fim▁begin|>class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
if not s:
return True
start = 0
end = len(s)-1
s = s.lower()
while start < end:
while start < end and not s[start].isalnum():
start += 1
while start < end and not s[end].isalnum():
end -= 1
if s[start] == s[end]:
start += 1
end -= 1
else:
<|fim_middle|>
return True<|fim▁end|> | return False |
<|file_name|>leetcode.125.valid-palindrome.py<|end_file_name|><|fim▁begin|>class Solution(object):
def <|fim_middle|>(self, s):
"""
:type s: str
:rtype: bool
"""
if not s:
return True
start = 0
end = len(s)-1
s = s.lower()
while start < end:
while start < end and not s[start].isalnum():
start += 1
while start < end and not s[end].isalnum():
end -= 1
if s[start] == s[end]:
start += 1
end -= 1
else:
return False
return True<|fim▁end|> | isPalindrome |
<|file_name|>gen_test2111b.py<|end_file_name|><|fim▁begin|>mcinif='mcini_gen2'
runname='gen_test2111b'
mcpick='gen_test2b.pickle'
pathdir='/beegfs/work/ka_oj4748/echoRD'
wdir='/beegfs/work/ka_oj4748/gen_tests'
update_prec=0.04
update_mf=False
update_part=500
import sys<|fim▁hole|>import run_echoRD as rE
rE.echoRD_job(mcinif=mcinif,mcpick=mcpick,runname=runname,wdir=wdir,pathdir=pathdir,update_prec=update_prec,update_mf=update_mf,update_part=update_part,hdf5pick=False)<|fim▁end|> | sys.path.append(pathdir)
|
<|file_name|>hello_text.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
import pygame
pygame.display.init()
pygame.font.init()
modes_list = pygame.display.list_modes()
#screen = pygame.display.set_mode(modes_list[0], pygame.FULLSCREEN) # the highest resolution with fullscreen
screen = pygame.display.set_mode(modes_list[-1]) # the lowest resolution
background_color = (255, 255, 255)
screen.fill(background_color)
font = pygame.font.Font(pygame.font.get_default_font(), 22)
text_surface = font.render("Hello world!", True, (0,0,0))
screen.blit(text_surface, (0,0)) # paste the text at the top left corner of the window
<|fim▁hole|>
while True: # main loop (event loop)
event = pygame.event.wait()
if(event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE)):
break<|fim▁end|> | pygame.display.flip() # display the image |
<|file_name|>hello_text.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
import pygame
pygame.display.init()
pygame.font.init()
modes_list = pygame.display.list_modes()
#screen = pygame.display.set_mode(modes_list[0], pygame.FULLSCREEN) # the highest resolution with fullscreen
screen = pygame.display.set_mode(modes_list[-1]) # the lowest resolution
background_color = (255, 255, 255)
screen.fill(background_color)
font = pygame.font.Font(pygame.font.get_default_font(), 22)
text_surface = font.render("Hello world!", True, (0,0,0))
screen.blit(text_surface, (0,0)) # paste the text at the top left corner of the window
pygame.display.flip() # display the image
while True: # main loop (event loop)
event = pygame.event.wait()
if(event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE)):
<|fim_middle|>
<|fim▁end|> | break |
<|file_name|>plotf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
import sys<|fim▁hole|>
def plot(files, fac=1.0):
for f in files:
if f.split('.')[-1] == 'xy':
td = np.loadtxt(f)
plt.plot(td[:, 0], np.log(1. / td[:, 1]) * fac, label=f)
elif f.split('.')[-1] == 'spc':
td = SPC(f)
plt.plot(td.xdata, np.log(1. / np.array(td.ydata)), label=f)
plt.legend()
plt.show()
if __name__ == '__main__':
files = sys.argv[2:]
fac = float(sys.argv[1])
plot(files, fac)<|fim▁end|> | import numpy as np
from spc import SPC
import matplotlib.pyplot as plt |
<|file_name|>plotf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
import sys
import numpy as np
from spc import SPC
import matplotlib.pyplot as plt
def plot(files, fac=1.0):
<|fim_middle|>
if __name__ == '__main__':
files = sys.argv[2:]
fac = float(sys.argv[1])
plot(files, fac)
<|fim▁end|> | for f in files:
if f.split('.')[-1] == 'xy':
td = np.loadtxt(f)
plt.plot(td[:, 0], np.log(1. / td[:, 1]) * fac, label=f)
elif f.split('.')[-1] == 'spc':
td = SPC(f)
plt.plot(td.xdata, np.log(1. / np.array(td.ydata)), label=f)
plt.legend()
plt.show() |
<|file_name|>plotf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
import sys
import numpy as np
from spc import SPC
import matplotlib.pyplot as plt
def plot(files, fac=1.0):
for f in files:
if f.split('.')[-1] == 'xy':
<|fim_middle|>
elif f.split('.')[-1] == 'spc':
td = SPC(f)
plt.plot(td.xdata, np.log(1. / np.array(td.ydata)), label=f)
plt.legend()
plt.show()
if __name__ == '__main__':
files = sys.argv[2:]
fac = float(sys.argv[1])
plot(files, fac)
<|fim▁end|> | td = np.loadtxt(f)
plt.plot(td[:, 0], np.log(1. / td[:, 1]) * fac, label=f) |
<|file_name|>plotf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
import sys
import numpy as np
from spc import SPC
import matplotlib.pyplot as plt
def plot(files, fac=1.0):
for f in files:
if f.split('.')[-1] == 'xy':
td = np.loadtxt(f)
plt.plot(td[:, 0], np.log(1. / td[:, 1]) * fac, label=f)
elif f.split('.')[-1] == 'spc':
<|fim_middle|>
plt.legend()
plt.show()
if __name__ == '__main__':
files = sys.argv[2:]
fac = float(sys.argv[1])
plot(files, fac)
<|fim▁end|> | td = SPC(f)
plt.plot(td.xdata, np.log(1. / np.array(td.ydata)), label=f) |
<|file_name|>plotf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
import sys
import numpy as np
from spc import SPC
import matplotlib.pyplot as plt
def plot(files, fac=1.0):
for f in files:
if f.split('.')[-1] == 'xy':
td = np.loadtxt(f)
plt.plot(td[:, 0], np.log(1. / td[:, 1]) * fac, label=f)
elif f.split('.')[-1] == 'spc':
td = SPC(f)
plt.plot(td.xdata, np.log(1. / np.array(td.ydata)), label=f)
plt.legend()
plt.show()
if __name__ == '__main__':
<|fim_middle|>
<|fim▁end|> | files = sys.argv[2:]
fac = float(sys.argv[1])
plot(files, fac) |
<|file_name|>plotf.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
import sys
import numpy as np
from spc import SPC
import matplotlib.pyplot as plt
def <|fim_middle|>(files, fac=1.0):
for f in files:
if f.split('.')[-1] == 'xy':
td = np.loadtxt(f)
plt.plot(td[:, 0], np.log(1. / td[:, 1]) * fac, label=f)
elif f.split('.')[-1] == 'spc':
td = SPC(f)
plt.plot(td.xdata, np.log(1. / np.array(td.ydata)), label=f)
plt.legend()
plt.show()
if __name__ == '__main__':
files = sys.argv[2:]
fac = float(sys.argv[1])
plot(files, fac)
<|fim▁end|> | plot |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)<|fim▁hole|> assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)<|fim▁end|> | time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1) |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
<|fim_middle|>
<|fim▁end|> | @pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min) |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
<|fim_middle|>
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | self.storage_url = "memcached://localhost:22122" |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
<|fim_middle|>
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1 |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
<|fim_middle|>
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min) |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
<|fim_middle|>
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min) |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
<|fim_middle|>
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec) |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
<|fim_middle|>
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec) |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
<|fim_middle|>
<|fim▁end|> | storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min) |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def <|fim_middle|>(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | setup |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def <|fim_middle|>(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | test_init_options |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def <|fim_middle|>(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | test_fixed_window |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def <|fim_middle|>(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | test_fixed_window_cluster |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def <|fim_middle|>(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | test_fixed_window_with_elastic_expiry |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def <|fim_middle|>(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def test_clear(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | test_fixed_window_with_elastic_expiry_cluster |
<|file_name|>test_memcached.py<|end_file_name|><|fim▁begin|>import time
import pymemcache.client
import pytest
from limits import RateLimitItemPerMinute, RateLimitItemPerSecond
from limits.storage import MemcachedStorage, storage_from_string
from limits.strategies import (
FixedWindowElasticExpiryRateLimiter,
FixedWindowRateLimiter,
)
from tests.utils import fixed_start
@pytest.mark.memcached
@pytest.mark.flaky
class TestMemcachedStorage:
@pytest.fixture(autouse=True)
def setup(self, memcached, memcached_cluster):
self.storage_url = "memcached://localhost:22122"
def test_init_options(self, mocker):
constructor = mocker.spy(pymemcache.client, "PooledClient")
assert storage_from_string(self.storage_url, connect_timeout=1).check()
assert constructor.call_args[1]["connect_timeout"] == 1
@fixed_start
def test_fixed_window(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerSecond(10)
start = time.time()
count = 0
while time.time() - start < 0.5 and count < 10:
assert limiter.hit(per_min)
count += 1
assert not limiter.hit(per_min)
while time.time() - start <= 1:
time.sleep(0.1)
assert limiter.hit(per_min)
@fixed_start
def test_fixed_window_with_elastic_expiry(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
@fixed_start
def test_fixed_window_with_elastic_expiry_cluster(self):
storage = MemcachedStorage("memcached://localhost:22122,localhost:22123")
limiter = FixedWindowElasticExpiryRateLimiter(storage)
per_sec = RateLimitItemPerSecond(2, 2)
assert limiter.hit(per_sec)
time.sleep(1)
assert limiter.hit(per_sec)
assert not limiter.test(per_sec)
time.sleep(1)
assert not limiter.test(per_sec)
time.sleep(1)
assert limiter.test(per_sec)
def <|fim_middle|>(self):
storage = MemcachedStorage("memcached://localhost:22122")
limiter = FixedWindowRateLimiter(storage)
per_min = RateLimitItemPerMinute(1)
limiter.hit(per_min)
assert not limiter.hit(per_min)
limiter.clear(per_min)
assert limiter.hit(per_min)
<|fim▁end|> | test_clear |
<|file_name|>wsgi.py<|end_file_name|><|fim▁begin|>"""
WSGI config for GoodDog project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""
import os<|fim▁hole|>from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "GoodDog.settings")
application = get_wsgi_application()<|fim▁end|> | |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")<|fim▁hole|>yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV")
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")<|fim▁end|> | print("###################################################")
# Setup the x and y variables
xValue = None |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
<|fim_middle|>
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV")
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | break # stops the loop |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
<|fim_middle|>
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV") |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
<|fim_middle|>
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV")
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | xValue = int(coordinate) |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
<|fim_middle|>
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV")
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | yValue = int(coordinate) |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
<|fim_middle|>
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV")
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | print("Origin") |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
<|fim_middle|>
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV") |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
<|fim_middle|>
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV")
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | print("Y - Axis") |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
<|fim_middle|>
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV")
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | print("X - Axis") |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
<|fim_middle|>
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV") |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
<|fim_middle|>
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV")
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | print("Quadrant I") |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
<|fim_middle|>
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV")
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | print("Quadrant II") |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
<|fim_middle|>
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV")
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | print("Quadrant III") |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
<|fim_middle|>
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
print("Please type the input value as x,y")
print("Example: 1,-9")
<|fim▁end|> | print("Quadrant IV") |
<|file_name|>check-quadrant.py<|end_file_name|><|fim▁begin|># Brandon Michael
# cis142
# checkForQuadrant.py
# Goal: This program will keep asking for input values to check for the quadrant postion,
# origin, x-axis and y axis postions
# Notes: I used a while loop to make testing values easier and I used the input x,y
# Display program instructions
print("###################################################")
print("Quadrant Finder 1.0")
print("Enter the x and y coordinates to find the quadrant!")
print("Type [exit] to quit the program")
print("###################################################")
# Setup the x and y variables
xValue = None
yValue = None
# Setup a loop that breaks when you type exit
while True:
# Get the input values in a X,Y format
inputCoordinates = input("Type in coordinates [x,y]: ")
# Check if exit was typed, if so then exit the loop and end
if inputCoordinates == "exit":
break # stops the loop
# We want to make sure we can only strip out 2 input values
# and make sure there is a comma separating them
elif len(inputCoordinates.strip().split(',')) == 2 and inputCoordinates.count(',') == 1:
# Loop over the two numbers that are stripped out by the comma value
for coordinate in inputCoordinates.strip().split(','):
# This checks to see if we have set a value for x
# If it is still set to None then the first value is going to be xValue
if xValue is None:
xValue = int(coordinate)
# Since we are checking the xValue we can assume when the loop comes back
# a second time we can set it to yValue
else:
yValue = int(coordinate)
# If its a 0,0 value then its the Origin
if xValue == 0 and yValue == 0:
print("Origin")
else:
# If x = 0 and the y is greater or less than 0 its on the Y axis
if xValue == 0 and (yValue < 0 or yValue > 0):
print("Y - Axis")
# If x is greater or less than 0 and y = 0 its on the X axis
elif (xValue < 0 or xValue > 0) and yValue == 0:
print("X - Axis")
# Anything else and we need to check for quadrants
else:
# If x is a positive number and y is a negative positive its in Quadrant 1
if xValue > 0 and yValue > 0:
print("Quadrant I")
# If x is a negative number and y is a positive number then its in Quadrant 2
elif xValue < 0 and yValue > 0:
print("Quadrant II")
# If x is a negative number and y is negative number then its in Quadrant 3
elif xValue < 0 and yValue < 0:
print("Quadrant III")
# If x is a positive number and y is a negative number then its in Quadrant 4
elif xValue > 0 and yValue < 0:
print("Quadrant IV")
# If they typed anything but 2 numbers separated by a comma then ask for the input again
else:
<|fim_middle|>
<|fim▁end|> | print("Please type the input value as x,y")
print("Example: 1,-9") |
<|file_name|>__openerp__.py<|end_file_name|><|fim▁begin|>{
'name' : 'Signature templates for user emails',
'version' : '1.0.0',
'author' : 'IT-Projects LLC, Ivan Yelizariev',<|fim▁hole|> 'depends' : ['base'],
'data':[
'res_users_signature_views.xml',
'security/res_users_signature_security.xml',
'security/ir.model.access.csv',
],
'installable': False
}<|fim▁end|> | 'license': 'LGPL-3',
'category' : 'Social Network',
'website' : 'https://yelizariev.github.io', |
<|file_name|>admin.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""
pythoner.net
Copyright (C) 2013 PYTHONER.ORG
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
<|fim▁hole|>You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from django.contrib import admin
from models import *
class ProfileAdmin(admin.ModelAdmin):
list_display = ('screen_name','city','introduction')
admin.site.register(UserProfile,ProfileAdmin)<|fim▁end|> | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
|
<|file_name|>admin.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""
pythoner.net
Copyright (C) 2013 PYTHONER.ORG
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from django.contrib import admin
from models import *
class ProfileAdmin(admin.ModelAdmin):
<|fim_middle|>
admin.site.register(UserProfile,ProfileAdmin)<|fim▁end|> | list_display = ('screen_name','city','introduction') |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]<|fim▁hole|> if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))<|fim▁end|> | |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
<|fim_middle|>
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
<|fim_middle|>
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
<|fim_middle|>
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
<|fim_middle|>
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
<|fim_middle|>
<|fim▁end|> | def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date))) |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
<|fim_middle|>
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end() |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
<|fim_middle|>
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies) |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
<|fim_middle|>
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0)))) |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
<|fim_middle|>
<|fim▁end|> | amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date))) |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
<|fim_middle|>
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | yield (row, self.company_id) |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
<|fim_middle|>
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | correct_day = True |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
<|fim_middle|>
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0)))) |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
<|fim_middle|>
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0)))) |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def <|fim_middle|>(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | __init__ |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def <|fim_middle|>(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | get_dates |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def <|fim_middle|>(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | get_row |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def <|fim_middle|>(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | build_stream |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def <|fim_middle|>(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | __process_companies |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def <|fim_middle|>(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def __process_row(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | __process_date |
<|file_name|>processor.py<|end_file_name|><|fim▁begin|>import csv
import decimal
import os
import datetime
from stocker.common.events import EventStreamNew, EventStockOpen, EventStockClose
from stocker.common.orders import OrderBuy, OrderSell
from stocker.common.utils import Stream
class CompanyProcessor(object):
def __init__(self, dirname, company_id):
self.dirname = os.path.join(dirname, company_id)
self.company_id = company_id
def get_dates(self):
files = [os.path.splitext(fi)[0] for fi in os.walk(self.dirname).next()[2]]
return files
def get_row(self, date):
filename = os.path.join(self.dirname, date) + ".csv"
try:
with open(filename, 'r') as f:
for row in reversed(list(csv.reader(f, delimiter=';'))):
try:
desc = row[5]
if desc.startswith('TRANSAKCJA'):
yield (row, self.company_id)
except IndexError:
pass
except IOError as e:
return
class Processor(object):
def build_stream(self, dirname_in, filename_out):
self.stream = Stream()
self.stream.begin(filename_out)
self.__process_companies(dirname_in)
self.stream.end()
def __process_companies(self, dirname):
companies = []
for company in os.walk(dirname).next()[1]:
companies.append(CompanyProcessor(dirname, company))
dates_set = set()
for company in companies:
dates_set.update(company.get_dates())
dates_ordered = sorted(dates_set, key=lambda date: datetime.datetime.strptime(date, "%Y-%m-%d"))
for date in dates_ordered:
self.__process_date(date, companies)
def __process_date(self, date, companies):
rows = []
correct_generators = []
correct_day = False
generators = [company.get_row(date) for company in companies]
for generator in generators:
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
correct_generators.append(generator)
except StopIteration as e:
pass
if correct_generators:
# correct day (have transactions)
correct_day = True
if correct_day:
self.stream.add_event(EventStockOpen(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(9, 0))))
# main loop, multiplexing rows
while correct_generators:
row_data = min(rows, key=lambda row: datetime.datetime.strptime(row[1][0], "%H:%M:%S"))
rows.remove(row_data)
company_id, row, generator = row_data
self.__process_row(row, date, company_id)
try:
row, company_id = generator.next()
row = (company_id, row, generator)
rows.append(row)
except StopIteration as e:
correct_generators.remove(generator)
if correct_day:
self.stream.add_event(EventStockClose(
datetime.datetime.combine(datetime.datetime.strptime(date, "%Y-%m-%d"), datetime.time(18, 0))))
def <|fim_middle|>(self, row, date, company_id):
amount = int(row[3])
limit_price = decimal.Decimal(row[1].replace(',', '.'))
timestamp = datetime.datetime.strptime("%s %s" % (date, row[0]), "%Y-%m-%d %H:%M:%S")
expiration_date = timestamp + datetime.timedelta(days=1)
self.stream.add_event(
EventStreamNew(timestamp, OrderBuy(company_id, amount, limit_price, expiration_date)))
self.stream.add_event(
EventStreamNew(timestamp, OrderSell(company_id, amount, limit_price, expiration_date)))
<|fim▁end|> | __process_row |
<|file_name|>_defines.py<|end_file_name|><|fim▁begin|>__author__ = 'sei'<|fim▁hole|>
DEFAULT_SERIAL = '/dev/ttyUSB0'
DEFAULT_BAUDRATE = 57600<|fim▁end|> | |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
<|fim▁hole|>
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)<|fim▁end|> | @route('/tags')
def bmarks():
return_data = get_tags()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
<|fim_middle|>
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return_data = get_index()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
<|fim_middle|>
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return_data = get_bmarklet()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
<|fim_middle|>
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return_data = add_tags()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
<|fim_middle|>
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return_data = get_bmarklet()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
<|fim_middle|>
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return_data = get_bmarks()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
<|fim_middle|>
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return_data = do_edit()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
<|fim_middle|>
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return_data = get_edit_tags()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
<|fim_middle|>
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return_data = get_import_bm()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
<|fim_middle|>
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return_data = do_login()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
<|fim_middle|>
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return_data = do_register()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
<|fim_middle|>
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return_data = get_tags()
return return_data |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
<|fim_middle|>
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return static_file(filename, root='css') |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
<|fim_middle|>
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return static_file(filename, root='js') |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
<|fim_middle|>
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return static_file(filename, root='images') |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
<|fim_middle|>
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return static_file(filename, root='fonts') |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
<|fim_middle|>
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | return '<H1>Ooops, its not here<BR>' |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
<|fim_middle|>
<|fim▁end|> | return '<H1>Oops, its broken: {}<BR>'.format(error) |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def <|fim_middle|>():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | myroot |
<|file_name|>tastiapp.py<|end_file_name|><|fim▁begin|>from bottle import route, template, error, request, static_file, get, post
from index import get_index
from bmarks import get_bmarks
from tags import get_tags
from add import add_tags
from bmarklet import get_bmarklet
from account import get_account
from edit_tags import get_edit_tags
from importbm import get_import_bm
from edit import do_edit
from login import do_login
from register import do_register
@route('/')
def myroot():
return_data = get_index()
return return_data
@route('/account', method=['GET', 'POST'])
def <|fim_middle|>():
return_data = get_bmarklet()
return return_data
@route('/add', method=['GET', 'POST'])
def bmarks():
return_data = add_tags()
return return_data
@route('/bmarklet')
def bmarks():
return_data = get_bmarklet()
return return_data
@route('/bmarks')
def bmarks():
return_data = get_bmarks()
return return_data
@route('/edit', method=['GET', 'POST'])
def bmarks():
return_data = do_edit()
return return_data
@route('/edit_tags', method=['GET', 'POST'])
def bmarks():
return_data = get_edit_tags()
return return_data
@route('/import', method=['GET', 'POST'])
def bmarks():
return_data = get_import_bm()
return return_data
@route('/login', method=['GET', 'POST'])
def bmarks():
return_data = do_login()
return return_data
@route('/register', method=['GET', 'POST'])
def bmarks():
return_data = do_register()
return return_data
@route('/tags')
def bmarks():
return_data = get_tags()
return return_data
# serve css
@get('/<filename:re:.*\.css>')
def send_css(filename):
return static_file(filename, root='css')
# serve javascript
@get('/<filename:re:.*\.js>')
def send_js(filename):
return static_file(filename, root='js')
# serve images
@get('<filename:re:.*\.png>')
def send_img(filename):
return static_file(filename, root='images')
# serve fonts
@get('<filename:re:.*\.(woff|woff2)>')
def send_font(filename):
return static_file(filename, root='fonts')
@error(404)
def handle404(error):
return '<H1>Ooops, its not here<BR>'
@error(500)
def handle500(error):
return '<H1>Oops, its broken: {}<BR>'.format(error)
<|fim▁end|> | bmarks |
Subsets and Splits