def __init__(self, x, y, angle=0.0, w=100, h=160, sizescale=1.0): self.x = x self.y = y self.angle = angle self.w, self.h, self.sizescale = w, h, sizescale self.sensors = [ Sensor(self, 1.03125 * self.h, self.w / 4, angle=+radians(20)), Sensor(self, 1.03125 * self.h, -self.w / 4, angle=-radians(20)) ] wheel_size = (self.sizescale * 40, self.sizescale * 20) self.left_wheel = Wheel(self, 0, -self.w / 2, side='left', size=wheel_size) self.right_wheel = Wheel(self, 0, self.w / 2, side='right', size=wheel_size) self.links = [ Link(self.sensors[0].plug, self.left_wheel.plug), Link(self.sensors[0].plug, self.right_wheel.plug, w0=0.0), Link(self.sensors[1].plug, self.left_wheel.plug, w0=0.0), Link(self.sensors[1].plug, self.right_wheel.plug), ]
class LinkedStack(AbstractStack): '''Stack implemented by link.''' def __init__(self, items=None): self._items = Link() AbstractStack.__init__(self, items) def clear(self): self._items = Link() def pop(self): if self.isEmpty(): raise KeyError('The stack is empty') return self._items.pop(0) def push(self, item): self._items.insert(0, item) def peek(self): if self.isEmpty(): raise KeyError('The stack is empty') return self._items[0] def __len__(self): '''Return the size of the stack.''' return len(self._items) def __str__(self): '''Print from bottom to top.''' return ' '.join(map(str, self)) def __iter__(self): '''Get item from bottom to top, but not pop them out.''' tmpList = list(self._items) for item in tmpList[::-1]: yield item
def main(): # получим логин, пароль из файла auth.ini auth = configparser.ConfigParser() auth.optionxform = str auth.read('auth.ini') settings = configparser.ConfigParser() settings.optionxform = str settings.read('settings.ini') # создадим объект аторизации a = Authentication(auth['Authorization']['Login'], auth['Authorization']['Password'], dict(settings['Browser Headers'])) print(a.uid) # создадим объект коллекции # c = Collection(a) # print(c.req_id, c.csrf_token, sep='\n') # new_coll = c.create('new-coll1', 'description new-coll1') # создадим карточку-ссылку link = 'https://zip-sm.ru/product/mufta-motora-kuhonnogo-kombajna-kenwood' collection_url = 'https://yandex.ru/collections/user/company%40zip/mekhanika-dlia-blenderov-zapchasti-dlia-miasorubok-i-blenderov/' l = Link(a, link, collection_url) print(l.link, l.collection_url, l.collection_id, sep='\n')
def index(): links = (Link( name="Productivity In Tech", url="https://productivityintech.transistor.fm", image="https://s3-us-west-2.amazonaws.com/kjaymiller/images/pit-podcast.png", ), Link( name=".Net Core Show", url="https://dotnetcore.show", image="https://dotnetcore.show/content/images/2018/08/jamie-taylor-logo-podcast.svg" ), Link( name="Ask A Brit", url="https://askabrit.transistor.fm", image="https://kjaymiller.s3-us-west-2.amazonaws.com/images/AskABritv4.png" ) ) return Page(template='index.html', links=links).html
def find_all_links(notes): backreferences = defaultdict(OrderedSet) out_links = dict() for note in notes: out_links[note.uid] = list(note.outgoing_links) for out_link in out_links[note.uid]: if not is_a_backreference(out_link): backref = Link(href_id=note.uid, title=note.title, open_note_title=BACKREFMARKER) backreferences[out_link.href_id].add(backref) return backreferences, out_links
def _string_to_link(self, l): """ Parses a link header string to a dictionary """ uri = re.search('<([^>]*)', l) and re.search('<([^>]*)', l).group(1) rest = re.search('.*>(.*)', l) and re.search('.*>(.*)', l).group(1) rel = (re.search('rel=(.*)', rest) and re.search('rel="(.*)"', rest).group(1)) tpe = (re.search('type=(.*)', rest) and re.search('type="(.*)"', rest).group(1)) return Link(href=uri, rel=rel, content_type=tpe)
def find_all_links(notes): backreferences = defaultdict(OrderedSet) out_links = dict() for note in notes.values(): if "#_daily" in note.text: continue out_links[note.title] = list(note.outgoing_links) for out_link in out_links[note.title]: if not is_a_backreference(out_link): backref = Link(title=note.title) backreferences[out_link.title].add(backref) return backreferences, out_links
def clear(self): self._items = Link()
def __init__(self, items=None): self._items = Link() AbstractStack.__init__(self, items)
SITE_URL = "https://jayandjay.media" OWNER = { 'name': 'Jay Miller', 'email': '*****@*****.**', } AUTHOR = 'KJAYMILLER' AUTHOR_IMAGE = '' AUTHOR_URL = 'https://kjaymiller.com' REGION = 'US/Pacific' BASE_PATH = 'content' OUTPUT_PATH = 'output' # Header Links CONTENT_PATH = 'content' OUTPUT_PATH = 'output' STATIC_PATH = 'static' TIME_FORMAT = 'MMMM DD, YYYY HH:mm' ICON = '' FAVICON = '' DEFAULT_POST_IMAGE = '' DEFAULT_POST_BANNER = '' LOGO = 'static/images/jayandjaymedia.png' HEADER_LINKS = ( Link(name='Blog', url='/blog/blog_0'), Link(name='Contact', url='/contact.html'), )
def test_handling_repository_error(error_prone_links_service): links = [Link.from_ts('ya.ru', 1)] with pytest.raises(Exception, match='Some error during saving'): error_prone_links_service.visit(links)
import pytest from links import InvalidInputData from links import Link @pytest.mark.parametrize( 'links,wrong_url', [ ([Link.from_ts('123', 1)], '123') ] ) def test_attempting_save_incorrect_url( in_memory_links_service, links, wrong_url): with pytest.raises(InvalidInputData, match=f'Url "{wrong_url}" is incorrect'): in_memory_links_service.visit(links) def test_handling_repository_error(error_prone_links_service): links = [Link.from_ts('ya.ru', 1)] with pytest.raises(Exception, match='Some error during saving'): error_prone_links_service.visit(links)
AUTHOR = 'KJAYMILLER' AUTHOR_EMAIL = '*****@*****.**' AUTHOR_URL = 'https://kjaymiller.com' AUTHOR_IMAGE = '' REGION = 'US/Pacific' TIME_FORMAT = 'MMMM DD, YYYY HH:mm' CONTENT_PATH = 'content' OUTPUT_PATH = 'output' STATIC_PATH = 'static' ICON = '' FAVICON = '' DEFAULT_POST_IMAGE = '' DEFAULT_POST_BANNER = '' HEADER_LINKS = ( Link(name='Blog', url='/blog/blog_0.html'), Link(name='Newsletter', url='/subscribe.html'), Link('Contact', '/contact.html'), Link( 'YouTube', 'https://www.youtube.com/channel/UCjoJU65IbXkKXsNqydro05Q?view_as=subscriber' ), Link( 'Podcasts', links=[ Link( name='Productivity in Tech Podcast', url='https://productivityintech.transistor.fm', image= "https://s3-us-west-2.amazonaws.com/kjaymiller/images/pit-podcast.png" ),