prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def push (self, data): <|fim_middle|> def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
self.stack.append(data)
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def push (self, data): self.stack.append(data) def peek (self): <|fim_middle|> def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
if self.isEmpty(): return None return self.stack[-1]
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def push (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): <|fim_middle|> def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
if self.isEmpty(): return None return self.stack.pop()
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def push (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): <|fim_middle|> def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
return len(self.stack) == 0
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def push (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): <|fim_middle|> <|fim▁end|>
return ' '.join(str(x) for x in self.stack)
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def push (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): <|fim_middle|> return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
return None
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def push (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): <|fim_middle|> return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
return None
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def <|fim_middle|> (self): self.stack = [] def push (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
__init__
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def <|fim_middle|> (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
push
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def push (self, data): self.stack.append(data) def <|fim_middle|> (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
peek
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def push (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def <|fim_middle|> (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
pop
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def push (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def <|fim_middle|> (self): return len(self.stack) == 0 def __str__ (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
isEmpty
<|file_name|>stack.py<|end_file_name|><|fim▁begin|># Stack implementation class Stack (object): def __init__ (self): self.stack = [] def push (self, data): self.stack.append(data) def peek (self): if self.isEmpty(): return None return self.stack[-1] def pop (self): if self.isEmpty(): return None return self.stack.pop() def isEmpty (self): return len(self.stack) == 0 def <|fim_middle|> (self): return ' '.join(str(x) for x in self.stack) <|fim▁end|>
__str__
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name<|fim▁hole|> if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None<|fim▁end|>
def if_or_max(self):
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: <|fim_middle|> class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): <|fim_middle|> def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): <|fim_middle|> def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
return '%s:%s' % (self.id, self.group_name)
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): <|fim_middle|> def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): <|fim_middle|> class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
if self.id: return int(self.id) else: return maxsize
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: <|fim_middle|> <|fim▁end|>
def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): <|fim_middle|> def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
self.app = app
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): <|fim_middle|> def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click()
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): <|fim_middle|> def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]"))
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): <|fim_middle|> def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page()
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): <|fim_middle|> def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text)
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): <|fim_middle|> def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): <|fim_middle|> def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
self.delete_group_by_index(0)
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): <|fim_middle|> group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click()
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): <|fim_middle|> def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache)
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): <|fim_middle|> def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click()
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): <|fim_middle|> def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): <|fim_middle|> <|fim▁end|>
wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: <|fim_middle|> else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
return int(self.id)
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: <|fim_middle|> class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
return maxsize
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): <|fim_middle|> def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
wd.find_element_by_link_text("groups").click()
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: <|fim_middle|> def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
self.create(Group(group_name='test')) self.click_group_page()
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: <|fim_middle|> def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text)
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: <|fim_middle|> return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id))
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def <|fim_middle|>(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
__init__
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def <|fim_middle|>(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
__repr__
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def <|fim_middle|>(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
__eq__
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def <|fim_middle|>(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
if_or_max
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def <|fim_middle|>(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
__init__
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def <|fim_middle|>(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
open_group_page
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def <|fim_middle|>(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
count
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def <|fim_middle|>(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
validation_of_group_exist
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def <|fim_middle|>(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
group_line
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def <|fim_middle|>(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
create
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def <|fim_middle|>(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
delete_first_group
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def <|fim_middle|>(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
click_group_page
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def <|fim_middle|>(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
get_group_list
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def <|fim_middle|>(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
select_group_by_index
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def <|fim_middle|>(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def edit_group_by_index(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
delete_group_by_index
<|file_name|>group_lib.py<|end_file_name|><|fim▁begin|>from sys import maxsize class Group: def __init__(self, group_name=None, group_header=None, group_footer=None, id=None): self.group_name = group_name self.group_header = group_header self.group_footer = group_footer self.id = id def __repr__(self): return '%s:%s' % (self.id, self.group_name) def __eq__(self, other): return (self.id is None or other.id is None or self.id == other.id) and self.group_name == other.group_name def if_or_max(self): if self.id: return int(self.id) else: return maxsize class GroupBase: def __init__(self, app): self.app = app def open_group_page(self): wd = self.app.wd if not (wd.current_url.endswith('/group.php') and len(wd.find_elements_by_name('new')) > 0): wd.find_element_by_link_text("groups").click() def count(self): wd = self.app.wd self.open_group_page() return len(wd.find_elements_by_name("selected[]")) def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page() def group_line(self, field, text): wd = self.app.wd if text: wd.find_element_by_name(field).click() wd.find_element_by_name(field).clear() wd.find_element_by_name(field).send_keys(text) def create(self, Group): wd = self.app.wd self.open_group_page() wd.find_element_by_name("new").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("submit").click() self.group_cache = None def delete_first_group(self): self.delete_group_by_index(0) def click_group_page(self): wd = self.app.wd wd.find_element_by_css_selector("div.msgbox").click() wd.find_element_by_link_text("group page").click() group_cache = None def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute('value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache) def select_group_by_index(self, index): wd = self.app.wd wd.find_elements_by_name("selected[]")[index].click() def delete_group_by_index(self, index): wd = self.app.wd self.open_group_page() self.select_group_by_index(index) wd.find_element_by_name('delete').click() self.click_group_page() self.group_cache = None def <|fim_middle|>(self, Group, index): wd = self.app.wd self.open_group_page() wd.find_elements_by_name("selected[]")[index].click() wd.find_element_by_name("edit").click() self.group_line('group_name', Group.group_name) self.group_line('group_header', Group.group_header) self.group_line('group_footer', Group.group_footer) wd.find_element_by_name("update").click() wd.find_element_by_link_text("groups").click() self.group_cache = None <|fim▁end|>
edit_group_by_index
<|file_name|>Identifier.py<|end_file_name|><|fim▁begin|>import numpy as np import pandas as pd from pandas import Series, DataFrame from scipy.spatial import distance import matplotlib.pyplot as plt from sklearn.cluster import DBSCAN from sklearn import metrics from sklearn.datasets.samples_generator import make_blobs from sklearn.preprocessing import StandardScaler from sklearn import decomposition # PCA from sklearn.metrics import confusion_matrix import json import ml.Features as ft from utils import Utils class Identifier(object): def __init__(self): columns = ['mean_height', 'min_height', 'max_height', 'mean_width', 'min_width', 'max_width', 'time', 'girth','id'] self.data = DataFrame(columns=columns) self.event = [] @staticmethod def subscribe(ch, method, properties, body): """ prints the body message. It's the default callback method :param ch: keep null :param method: keep null :param properties: keep null :param body: the message :return: """ #first we get the JSON from body #we check if it's part of the walking event #if walking event is completed, we if __name__ == '__main__': # we setup needed params MAX_HEIGHT = 203 MAX_WIDTH = 142 SPEED = 3<|fim▁hole|> # setting up MQTT subscriber Utils.sub(queue_name=queue_name,callback=subscribe,host=mq_host)<|fim▁end|>
SAMPLING_RATE = 8 mq_host = '172.26.56.122' queue_name = 'door_data'
<|file_name|>Identifier.py<|end_file_name|><|fim▁begin|>import numpy as np import pandas as pd from pandas import Series, DataFrame from scipy.spatial import distance import matplotlib.pyplot as plt from sklearn.cluster import DBSCAN from sklearn import metrics from sklearn.datasets.samples_generator import make_blobs from sklearn.preprocessing import StandardScaler from sklearn import decomposition # PCA from sklearn.metrics import confusion_matrix import json import ml.Features as ft from utils import Utils class Identifier(object): <|fim_middle|> if __name__ == '__main__': # we setup needed params MAX_HEIGHT = 203 MAX_WIDTH = 142 SPEED = 3 SAMPLING_RATE = 8 mq_host = '172.26.56.122' queue_name = 'door_data' # setting up MQTT subscriber Utils.sub(queue_name=queue_name,callback=subscribe,host=mq_host)<|fim▁end|>
def __init__(self): columns = ['mean_height', 'min_height', 'max_height', 'mean_width', 'min_width', 'max_width', 'time', 'girth','id'] self.data = DataFrame(columns=columns) self.event = [] @staticmethod def subscribe(ch, method, properties, body): """ prints the body message. It's the default callback method :param ch: keep null :param method: keep null :param properties: keep null :param body: the message :return: """ #first we get the JSON from body #we check if it's part of the walking event #if walking event is completed, we
<|file_name|>Identifier.py<|end_file_name|><|fim▁begin|>import numpy as np import pandas as pd from pandas import Series, DataFrame from scipy.spatial import distance import matplotlib.pyplot as plt from sklearn.cluster import DBSCAN from sklearn import metrics from sklearn.datasets.samples_generator import make_blobs from sklearn.preprocessing import StandardScaler from sklearn import decomposition # PCA from sklearn.metrics import confusion_matrix import json import ml.Features as ft from utils import Utils class Identifier(object): def __init__(self): <|fim_middle|> @staticmethod def subscribe(ch, method, properties, body): """ prints the body message. It's the default callback method :param ch: keep null :param method: keep null :param properties: keep null :param body: the message :return: """ #first we get the JSON from body #we check if it's part of the walking event #if walking event is completed, we if __name__ == '__main__': # we setup needed params MAX_HEIGHT = 203 MAX_WIDTH = 142 SPEED = 3 SAMPLING_RATE = 8 mq_host = '172.26.56.122' queue_name = 'door_data' # setting up MQTT subscriber Utils.sub(queue_name=queue_name,callback=subscribe,host=mq_host)<|fim▁end|>
columns = ['mean_height', 'min_height', 'max_height', 'mean_width', 'min_width', 'max_width', 'time', 'girth','id'] self.data = DataFrame(columns=columns) self.event = []
<|file_name|>Identifier.py<|end_file_name|><|fim▁begin|>import numpy as np import pandas as pd from pandas import Series, DataFrame from scipy.spatial import distance import matplotlib.pyplot as plt from sklearn.cluster import DBSCAN from sklearn import metrics from sklearn.datasets.samples_generator import make_blobs from sklearn.preprocessing import StandardScaler from sklearn import decomposition # PCA from sklearn.metrics import confusion_matrix import json import ml.Features as ft from utils import Utils class Identifier(object): def __init__(self): columns = ['mean_height', 'min_height', 'max_height', 'mean_width', 'min_width', 'max_width', 'time', 'girth','id'] self.data = DataFrame(columns=columns) self.event = [] @staticmethod def subscribe(ch, method, properties, body): <|fim_middle|> if __name__ == '__main__': # we setup needed params MAX_HEIGHT = 203 MAX_WIDTH = 142 SPEED = 3 SAMPLING_RATE = 8 mq_host = '172.26.56.122' queue_name = 'door_data' # setting up MQTT subscriber Utils.sub(queue_name=queue_name,callback=subscribe,host=mq_host)<|fim▁end|>
""" prints the body message. It's the default callback method :param ch: keep null :param method: keep null :param properties: keep null :param body: the message :return: """ #first we get the JSON from body #we check if it's part of the walking event #if walking event is completed, we
<|file_name|>Identifier.py<|end_file_name|><|fim▁begin|>import numpy as np import pandas as pd from pandas import Series, DataFrame from scipy.spatial import distance import matplotlib.pyplot as plt from sklearn.cluster import DBSCAN from sklearn import metrics from sklearn.datasets.samples_generator import make_blobs from sklearn.preprocessing import StandardScaler from sklearn import decomposition # PCA from sklearn.metrics import confusion_matrix import json import ml.Features as ft from utils import Utils class Identifier(object): def __init__(self): columns = ['mean_height', 'min_height', 'max_height', 'mean_width', 'min_width', 'max_width', 'time', 'girth','id'] self.data = DataFrame(columns=columns) self.event = [] @staticmethod def subscribe(ch, method, properties, body): """ prints the body message. It's the default callback method :param ch: keep null :param method: keep null :param properties: keep null :param body: the message :return: """ #first we get the JSON from body #we check if it's part of the walking event #if walking event is completed, we if __name__ == '__main__': # we setup needed params <|fim_middle|> <|fim▁end|>
MAX_HEIGHT = 203 MAX_WIDTH = 142 SPEED = 3 SAMPLING_RATE = 8 mq_host = '172.26.56.122' queue_name = 'door_data' # setting up MQTT subscriber Utils.sub(queue_name=queue_name,callback=subscribe,host=mq_host)
<|file_name|>Identifier.py<|end_file_name|><|fim▁begin|>import numpy as np import pandas as pd from pandas import Series, DataFrame from scipy.spatial import distance import matplotlib.pyplot as plt from sklearn.cluster import DBSCAN from sklearn import metrics from sklearn.datasets.samples_generator import make_blobs from sklearn.preprocessing import StandardScaler from sklearn import decomposition # PCA from sklearn.metrics import confusion_matrix import json import ml.Features as ft from utils import Utils class Identifier(object): def <|fim_middle|>(self): columns = ['mean_height', 'min_height', 'max_height', 'mean_width', 'min_width', 'max_width', 'time', 'girth','id'] self.data = DataFrame(columns=columns) self.event = [] @staticmethod def subscribe(ch, method, properties, body): """ prints the body message. It's the default callback method :param ch: keep null :param method: keep null :param properties: keep null :param body: the message :return: """ #first we get the JSON from body #we check if it's part of the walking event #if walking event is completed, we if __name__ == '__main__': # we setup needed params MAX_HEIGHT = 203 MAX_WIDTH = 142 SPEED = 3 SAMPLING_RATE = 8 mq_host = '172.26.56.122' queue_name = 'door_data' # setting up MQTT subscriber Utils.sub(queue_name=queue_name,callback=subscribe,host=mq_host)<|fim▁end|>
__init__
<|file_name|>Identifier.py<|end_file_name|><|fim▁begin|>import numpy as np import pandas as pd from pandas import Series, DataFrame from scipy.spatial import distance import matplotlib.pyplot as plt from sklearn.cluster import DBSCAN from sklearn import metrics from sklearn.datasets.samples_generator import make_blobs from sklearn.preprocessing import StandardScaler from sklearn import decomposition # PCA from sklearn.metrics import confusion_matrix import json import ml.Features as ft from utils import Utils class Identifier(object): def __init__(self): columns = ['mean_height', 'min_height', 'max_height', 'mean_width', 'min_width', 'max_width', 'time', 'girth','id'] self.data = DataFrame(columns=columns) self.event = [] @staticmethod def <|fim_middle|>(ch, method, properties, body): """ prints the body message. It's the default callback method :param ch: keep null :param method: keep null :param properties: keep null :param body: the message :return: """ #first we get the JSON from body #we check if it's part of the walking event #if walking event is completed, we if __name__ == '__main__': # we setup needed params MAX_HEIGHT = 203 MAX_WIDTH = 142 SPEED = 3 SAMPLING_RATE = 8 mq_host = '172.26.56.122' queue_name = 'door_data' # setting up MQTT subscriber Utils.sub(queue_name=queue_name,callback=subscribe,host=mq_host)<|fim▁end|>
subscribe
<|file_name|>GameState.py<|end_file_name|><|fim▁begin|>__author__ = 'miko' from Tkinter import Frame class GameState(Frame):<|fim▁hole|> Frame.__init__(self, self.root.mainWindow) self.config( background="gold" ) self.place(relwidth=1, relheight=1)<|fim▁end|>
def __init__(self, *args, **kwargs): self.stateName = kwargs["stateName"] self.root = args[0] self.id = kwargs["id"]
<|file_name|>GameState.py<|end_file_name|><|fim▁begin|>__author__ = 'miko' from Tkinter import Frame class GameState(Frame): <|fim_middle|> <|fim▁end|>
def __init__(self, *args, **kwargs): self.stateName = kwargs["stateName"] self.root = args[0] self.id = kwargs["id"] Frame.__init__(self, self.root.mainWindow) self.config( background="gold" ) self.place(relwidth=1, relheight=1)
<|file_name|>GameState.py<|end_file_name|><|fim▁begin|>__author__ = 'miko' from Tkinter import Frame class GameState(Frame): def __init__(self, *args, **kwargs): <|fim_middle|> <|fim▁end|>
self.stateName = kwargs["stateName"] self.root = args[0] self.id = kwargs["id"] Frame.__init__(self, self.root.mainWindow) self.config( background="gold" ) self.place(relwidth=1, relheight=1)
<|file_name|>GameState.py<|end_file_name|><|fim▁begin|>__author__ = 'miko' from Tkinter import Frame class GameState(Frame): def <|fim_middle|>(self, *args, **kwargs): self.stateName = kwargs["stateName"] self.root = args[0] self.id = kwargs["id"] Frame.__init__(self, self.root.mainWindow) self.config( background="gold" ) self.place(relwidth=1, relheight=1) <|fim▁end|>
__init__
<|file_name|>preprocess.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ Created on Fri Jun 25 16:20:12 2015 @author: Balázs Hidasi @lastmodified: Loreto Parisi (loretoparisi at gmail dot com) """ import sys import os import numpy as np import pandas as pd import datetime as dt # To redirect output to file class Logger(object): def __init__(self, filename="Default.log"): self.terminal = sys.stdout self.log = open(filename, "a") def write(self, message): self.terminal.write(message) self.log.write(message) def flush(self): pass sys.stdout = Logger( os.environ['HOME' ] + '/theano.log' ) PATH_TO_ORIGINAL_DATA = os.environ['HOME'] + '/' PATH_TO_PROCESSED_DATA = os.environ['HOME'] + '/' data = pd.read_csv(PATH_TO_ORIGINAL_DATA + 'yoochoose-clicks.dat', sep=',', header=None, usecols=[0,1,2], dtype={0:np.int32, 1:str, 2:np.int64}) data.columns = ['SessionId', 'TimeStr', 'ItemId'] data['Time'] = data.TimeStr.apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S.%fZ').timestamp()) #This is not UTC. It does not really matter. del(data['TimeStr']) session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>1].index)] item_supports = data.groupby('ItemId').size() data = data[np.in1d(data.ItemId, item_supports[item_supports>=5].index)] session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>=2].index)] tmax = data.Time.max() session_max_times = data.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_test = session_max_times[session_max_times >= tmax-86400].index<|fim▁hole|>test = test[np.in1d(test.SessionId, tslength[tslength>=2].index)] print('Full train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train), train.SessionId.nunique(), train.ItemId.nunique())) train.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_full.txt', sep='\t', index=False) print('Test set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(test), test.SessionId.nunique(), test.ItemId.nunique())) test.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_test.txt', sep='\t', index=False) tmax = train.Time.max() session_max_times = train.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_valid = session_max_times[session_max_times >= tmax-86400].index train_tr = train[np.in1d(train.SessionId, session_train)] valid = train[np.in1d(train.SessionId, session_valid)] valid = valid[np.in1d(valid.ItemId, train_tr.ItemId)] tslength = valid.groupby('SessionId').size() valid = valid[np.in1d(valid.SessionId, tslength[tslength>=2].index)] print('Train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train_tr), train_tr.SessionId.nunique(), train_tr.ItemId.nunique())) train_tr.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_tr.txt', sep='\t', index=False) print('Validation set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(valid), valid.SessionId.nunique(), valid.ItemId.nunique())) valid.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_valid.txt', sep='\t', index=False)<|fim▁end|>
train = data[np.in1d(data.SessionId, session_train)] test = data[np.in1d(data.SessionId, session_test)] test = test[np.in1d(test.ItemId, train.ItemId)] tslength = test.groupby('SessionId').size()
<|file_name|>preprocess.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ Created on Fri Jun 25 16:20:12 2015 @author: Balázs Hidasi @lastmodified: Loreto Parisi (loretoparisi at gmail dot com) """ import sys import os import numpy as np import pandas as pd import datetime as dt # To redirect output to file class Logger(object): d<|fim_middle|> sys.stdout = Logger( os.environ['HOME' ] + '/theano.log' ) PATH_TO_ORIGINAL_DATA = os.environ['HOME'] + '/' PATH_TO_PROCESSED_DATA = os.environ['HOME'] + '/' data = pd.read_csv(PATH_TO_ORIGINAL_DATA + 'yoochoose-clicks.dat', sep=',', header=None, usecols=[0,1,2], dtype={0:np.int32, 1:str, 2:np.int64}) data.columns = ['SessionId', 'TimeStr', 'ItemId'] data['Time'] = data.TimeStr.apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S.%fZ').timestamp()) #This is not UTC. It does not really matter. del(data['TimeStr']) session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>1].index)] item_supports = data.groupby('ItemId').size() data = data[np.in1d(data.ItemId, item_supports[item_supports>=5].index)] session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>=2].index)] tmax = data.Time.max() session_max_times = data.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_test = session_max_times[session_max_times >= tmax-86400].index train = data[np.in1d(data.SessionId, session_train)] test = data[np.in1d(data.SessionId, session_test)] test = test[np.in1d(test.ItemId, train.ItemId)] tslength = test.groupby('SessionId').size() test = test[np.in1d(test.SessionId, tslength[tslength>=2].index)] print('Full train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train), train.SessionId.nunique(), train.ItemId.nunique())) train.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_full.txt', sep='\t', index=False) print('Test set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(test), test.SessionId.nunique(), test.ItemId.nunique())) test.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_test.txt', sep='\t', index=False) tmax = train.Time.max() session_max_times = train.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_valid = session_max_times[session_max_times >= tmax-86400].index train_tr = train[np.in1d(train.SessionId, session_train)] valid = train[np.in1d(train.SessionId, session_valid)] valid = valid[np.in1d(valid.ItemId, train_tr.ItemId)] tslength = valid.groupby('SessionId').size() valid = valid[np.in1d(valid.SessionId, tslength[tslength>=2].index)] print('Train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train_tr), train_tr.SessionId.nunique(), train_tr.ItemId.nunique())) train_tr.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_tr.txt', sep='\t', index=False) print('Validation set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(valid), valid.SessionId.nunique(), valid.ItemId.nunique())) valid.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_valid.txt', sep='\t', index=False)<|fim▁end|>
ef __init__(self, filename="Default.log"): self.terminal = sys.stdout self.log = open(filename, "a") def write(self, message): self.terminal.write(message) self.log.write(message) def flush(self): pass
<|file_name|>preprocess.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ Created on Fri Jun 25 16:20:12 2015 @author: Balázs Hidasi @lastmodified: Loreto Parisi (loretoparisi at gmail dot com) """ import sys import os import numpy as np import pandas as pd import datetime as dt # To redirect output to file class Logger(object): def __init__(self, filename="Default.log"): s<|fim_middle|> def write(self, message): self.terminal.write(message) self.log.write(message) def flush(self): pass sys.stdout = Logger( os.environ['HOME' ] + '/theano.log' ) PATH_TO_ORIGINAL_DATA = os.environ['HOME'] + '/' PATH_TO_PROCESSED_DATA = os.environ['HOME'] + '/' data = pd.read_csv(PATH_TO_ORIGINAL_DATA + 'yoochoose-clicks.dat', sep=',', header=None, usecols=[0,1,2], dtype={0:np.int32, 1:str, 2:np.int64}) data.columns = ['SessionId', 'TimeStr', 'ItemId'] data['Time'] = data.TimeStr.apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S.%fZ').timestamp()) #This is not UTC. It does not really matter. del(data['TimeStr']) session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>1].index)] item_supports = data.groupby('ItemId').size() data = data[np.in1d(data.ItemId, item_supports[item_supports>=5].index)] session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>=2].index)] tmax = data.Time.max() session_max_times = data.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_test = session_max_times[session_max_times >= tmax-86400].index train = data[np.in1d(data.SessionId, session_train)] test = data[np.in1d(data.SessionId, session_test)] test = test[np.in1d(test.ItemId, train.ItemId)] tslength = test.groupby('SessionId').size() test = test[np.in1d(test.SessionId, tslength[tslength>=2].index)] print('Full train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train), train.SessionId.nunique(), train.ItemId.nunique())) train.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_full.txt', sep='\t', index=False) print('Test set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(test), test.SessionId.nunique(), test.ItemId.nunique())) test.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_test.txt', sep='\t', index=False) tmax = train.Time.max() session_max_times = train.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_valid = session_max_times[session_max_times >= tmax-86400].index train_tr = train[np.in1d(train.SessionId, session_train)] valid = train[np.in1d(train.SessionId, session_valid)] valid = valid[np.in1d(valid.ItemId, train_tr.ItemId)] tslength = valid.groupby('SessionId').size() valid = valid[np.in1d(valid.SessionId, tslength[tslength>=2].index)] print('Train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train_tr), train_tr.SessionId.nunique(), train_tr.ItemId.nunique())) train_tr.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_tr.txt', sep='\t', index=False) print('Validation set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(valid), valid.SessionId.nunique(), valid.ItemId.nunique())) valid.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_valid.txt', sep='\t', index=False)<|fim▁end|>
elf.terminal = sys.stdout self.log = open(filename, "a")
<|file_name|>preprocess.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ Created on Fri Jun 25 16:20:12 2015 @author: Balázs Hidasi @lastmodified: Loreto Parisi (loretoparisi at gmail dot com) """ import sys import os import numpy as np import pandas as pd import datetime as dt # To redirect output to file class Logger(object): def __init__(self, filename="Default.log"): self.terminal = sys.stdout self.log = open(filename, "a") def write(self, message): s<|fim_middle|> def flush(self): pass sys.stdout = Logger( os.environ['HOME' ] + '/theano.log' ) PATH_TO_ORIGINAL_DATA = os.environ['HOME'] + '/' PATH_TO_PROCESSED_DATA = os.environ['HOME'] + '/' data = pd.read_csv(PATH_TO_ORIGINAL_DATA + 'yoochoose-clicks.dat', sep=',', header=None, usecols=[0,1,2], dtype={0:np.int32, 1:str, 2:np.int64}) data.columns = ['SessionId', 'TimeStr', 'ItemId'] data['Time'] = data.TimeStr.apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S.%fZ').timestamp()) #This is not UTC. It does not really matter. del(data['TimeStr']) session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>1].index)] item_supports = data.groupby('ItemId').size() data = data[np.in1d(data.ItemId, item_supports[item_supports>=5].index)] session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>=2].index)] tmax = data.Time.max() session_max_times = data.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_test = session_max_times[session_max_times >= tmax-86400].index train = data[np.in1d(data.SessionId, session_train)] test = data[np.in1d(data.SessionId, session_test)] test = test[np.in1d(test.ItemId, train.ItemId)] tslength = test.groupby('SessionId').size() test = test[np.in1d(test.SessionId, tslength[tslength>=2].index)] print('Full train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train), train.SessionId.nunique(), train.ItemId.nunique())) train.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_full.txt', sep='\t', index=False) print('Test set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(test), test.SessionId.nunique(), test.ItemId.nunique())) test.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_test.txt', sep='\t', index=False) tmax = train.Time.max() session_max_times = train.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_valid = session_max_times[session_max_times >= tmax-86400].index train_tr = train[np.in1d(train.SessionId, session_train)] valid = train[np.in1d(train.SessionId, session_valid)] valid = valid[np.in1d(valid.ItemId, train_tr.ItemId)] tslength = valid.groupby('SessionId').size() valid = valid[np.in1d(valid.SessionId, tslength[tslength>=2].index)] print('Train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train_tr), train_tr.SessionId.nunique(), train_tr.ItemId.nunique())) train_tr.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_tr.txt', sep='\t', index=False) print('Validation set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(valid), valid.SessionId.nunique(), valid.ItemId.nunique())) valid.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_valid.txt', sep='\t', index=False)<|fim▁end|>
elf.terminal.write(message) self.log.write(message)
<|file_name|>preprocess.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ Created on Fri Jun 25 16:20:12 2015 @author: Balázs Hidasi @lastmodified: Loreto Parisi (loretoparisi at gmail dot com) """ import sys import os import numpy as np import pandas as pd import datetime as dt # To redirect output to file class Logger(object): def __init__(self, filename="Default.log"): self.terminal = sys.stdout self.log = open(filename, "a") def write(self, message): self.terminal.write(message) self.log.write(message) def flush(self): p<|fim_middle|> sys.stdout = Logger( os.environ['HOME' ] + '/theano.log' ) PATH_TO_ORIGINAL_DATA = os.environ['HOME'] + '/' PATH_TO_PROCESSED_DATA = os.environ['HOME'] + '/' data = pd.read_csv(PATH_TO_ORIGINAL_DATA + 'yoochoose-clicks.dat', sep=',', header=None, usecols=[0,1,2], dtype={0:np.int32, 1:str, 2:np.int64}) data.columns = ['SessionId', 'TimeStr', 'ItemId'] data['Time'] = data.TimeStr.apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S.%fZ').timestamp()) #This is not UTC. It does not really matter. del(data['TimeStr']) session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>1].index)] item_supports = data.groupby('ItemId').size() data = data[np.in1d(data.ItemId, item_supports[item_supports>=5].index)] session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>=2].index)] tmax = data.Time.max() session_max_times = data.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_test = session_max_times[session_max_times >= tmax-86400].index train = data[np.in1d(data.SessionId, session_train)] test = data[np.in1d(data.SessionId, session_test)] test = test[np.in1d(test.ItemId, train.ItemId)] tslength = test.groupby('SessionId').size() test = test[np.in1d(test.SessionId, tslength[tslength>=2].index)] print('Full train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train), train.SessionId.nunique(), train.ItemId.nunique())) train.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_full.txt', sep='\t', index=False) print('Test set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(test), test.SessionId.nunique(), test.ItemId.nunique())) test.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_test.txt', sep='\t', index=False) tmax = train.Time.max() session_max_times = train.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_valid = session_max_times[session_max_times >= tmax-86400].index train_tr = train[np.in1d(train.SessionId, session_train)] valid = train[np.in1d(train.SessionId, session_valid)] valid = valid[np.in1d(valid.ItemId, train_tr.ItemId)] tslength = valid.groupby('SessionId').size() valid = valid[np.in1d(valid.SessionId, tslength[tslength>=2].index)] print('Train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train_tr), train_tr.SessionId.nunique(), train_tr.ItemId.nunique())) train_tr.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_tr.txt', sep='\t', index=False) print('Validation set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(valid), valid.SessionId.nunique(), valid.ItemId.nunique())) valid.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_valid.txt', sep='\t', index=False)<|fim▁end|>
ass
<|file_name|>preprocess.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ Created on Fri Jun 25 16:20:12 2015 @author: Balázs Hidasi @lastmodified: Loreto Parisi (loretoparisi at gmail dot com) """ import sys import os import numpy as np import pandas as pd import datetime as dt # To redirect output to file class Logger(object): def _<|fim_middle|>self, filename="Default.log"): self.terminal = sys.stdout self.log = open(filename, "a") def write(self, message): self.terminal.write(message) self.log.write(message) def flush(self): pass sys.stdout = Logger( os.environ['HOME' ] + '/theano.log' ) PATH_TO_ORIGINAL_DATA = os.environ['HOME'] + '/' PATH_TO_PROCESSED_DATA = os.environ['HOME'] + '/' data = pd.read_csv(PATH_TO_ORIGINAL_DATA + 'yoochoose-clicks.dat', sep=',', header=None, usecols=[0,1,2], dtype={0:np.int32, 1:str, 2:np.int64}) data.columns = ['SessionId', 'TimeStr', 'ItemId'] data['Time'] = data.TimeStr.apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S.%fZ').timestamp()) #This is not UTC. It does not really matter. del(data['TimeStr']) session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>1].index)] item_supports = data.groupby('ItemId').size() data = data[np.in1d(data.ItemId, item_supports[item_supports>=5].index)] session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>=2].index)] tmax = data.Time.max() session_max_times = data.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_test = session_max_times[session_max_times >= tmax-86400].index train = data[np.in1d(data.SessionId, session_train)] test = data[np.in1d(data.SessionId, session_test)] test = test[np.in1d(test.ItemId, train.ItemId)] tslength = test.groupby('SessionId').size() test = test[np.in1d(test.SessionId, tslength[tslength>=2].index)] print('Full train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train), train.SessionId.nunique(), train.ItemId.nunique())) train.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_full.txt', sep='\t', index=False) print('Test set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(test), test.SessionId.nunique(), test.ItemId.nunique())) test.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_test.txt', sep='\t', index=False) tmax = train.Time.max() session_max_times = train.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_valid = session_max_times[session_max_times >= tmax-86400].index train_tr = train[np.in1d(train.SessionId, session_train)] valid = train[np.in1d(train.SessionId, session_valid)] valid = valid[np.in1d(valid.ItemId, train_tr.ItemId)] tslength = valid.groupby('SessionId').size() valid = valid[np.in1d(valid.SessionId, tslength[tslength>=2].index)] print('Train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train_tr), train_tr.SessionId.nunique(), train_tr.ItemId.nunique())) train_tr.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_tr.txt', sep='\t', index=False) print('Validation set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(valid), valid.SessionId.nunique(), valid.ItemId.nunique())) valid.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_valid.txt', sep='\t', index=False)<|fim▁end|>
_init__(
<|file_name|>preprocess.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ Created on Fri Jun 25 16:20:12 2015 @author: Balázs Hidasi @lastmodified: Loreto Parisi (loretoparisi at gmail dot com) """ import sys import os import numpy as np import pandas as pd import datetime as dt # To redirect output to file class Logger(object): def __init__(self, filename="Default.log"): self.terminal = sys.stdout self.log = open(filename, "a") def w<|fim_middle|>self, message): self.terminal.write(message) self.log.write(message) def flush(self): pass sys.stdout = Logger( os.environ['HOME' ] + '/theano.log' ) PATH_TO_ORIGINAL_DATA = os.environ['HOME'] + '/' PATH_TO_PROCESSED_DATA = os.environ['HOME'] + '/' data = pd.read_csv(PATH_TO_ORIGINAL_DATA + 'yoochoose-clicks.dat', sep=',', header=None, usecols=[0,1,2], dtype={0:np.int32, 1:str, 2:np.int64}) data.columns = ['SessionId', 'TimeStr', 'ItemId'] data['Time'] = data.TimeStr.apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S.%fZ').timestamp()) #This is not UTC. It does not really matter. del(data['TimeStr']) session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>1].index)] item_supports = data.groupby('ItemId').size() data = data[np.in1d(data.ItemId, item_supports[item_supports>=5].index)] session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>=2].index)] tmax = data.Time.max() session_max_times = data.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_test = session_max_times[session_max_times >= tmax-86400].index train = data[np.in1d(data.SessionId, session_train)] test = data[np.in1d(data.SessionId, session_test)] test = test[np.in1d(test.ItemId, train.ItemId)] tslength = test.groupby('SessionId').size() test = test[np.in1d(test.SessionId, tslength[tslength>=2].index)] print('Full train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train), train.SessionId.nunique(), train.ItemId.nunique())) train.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_full.txt', sep='\t', index=False) print('Test set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(test), test.SessionId.nunique(), test.ItemId.nunique())) test.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_test.txt', sep='\t', index=False) tmax = train.Time.max() session_max_times = train.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_valid = session_max_times[session_max_times >= tmax-86400].index train_tr = train[np.in1d(train.SessionId, session_train)] valid = train[np.in1d(train.SessionId, session_valid)] valid = valid[np.in1d(valid.ItemId, train_tr.ItemId)] tslength = valid.groupby('SessionId').size() valid = valid[np.in1d(valid.SessionId, tslength[tslength>=2].index)] print('Train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train_tr), train_tr.SessionId.nunique(), train_tr.ItemId.nunique())) train_tr.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_tr.txt', sep='\t', index=False) print('Validation set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(valid), valid.SessionId.nunique(), valid.ItemId.nunique())) valid.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_valid.txt', sep='\t', index=False)<|fim▁end|>
rite(
<|file_name|>preprocess.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- """ Created on Fri Jun 25 16:20:12 2015 @author: Balázs Hidasi @lastmodified: Loreto Parisi (loretoparisi at gmail dot com) """ import sys import os import numpy as np import pandas as pd import datetime as dt # To redirect output to file class Logger(object): def __init__(self, filename="Default.log"): self.terminal = sys.stdout self.log = open(filename, "a") def write(self, message): self.terminal.write(message) self.log.write(message) def f<|fim_middle|>self): pass sys.stdout = Logger( os.environ['HOME' ] + '/theano.log' ) PATH_TO_ORIGINAL_DATA = os.environ['HOME'] + '/' PATH_TO_PROCESSED_DATA = os.environ['HOME'] + '/' data = pd.read_csv(PATH_TO_ORIGINAL_DATA + 'yoochoose-clicks.dat', sep=',', header=None, usecols=[0,1,2], dtype={0:np.int32, 1:str, 2:np.int64}) data.columns = ['SessionId', 'TimeStr', 'ItemId'] data['Time'] = data.TimeStr.apply(lambda x: dt.datetime.strptime(x, '%Y-%m-%dT%H:%M:%S.%fZ').timestamp()) #This is not UTC. It does not really matter. del(data['TimeStr']) session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>1].index)] item_supports = data.groupby('ItemId').size() data = data[np.in1d(data.ItemId, item_supports[item_supports>=5].index)] session_lengths = data.groupby('SessionId').size() data = data[np.in1d(data.SessionId, session_lengths[session_lengths>=2].index)] tmax = data.Time.max() session_max_times = data.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_test = session_max_times[session_max_times >= tmax-86400].index train = data[np.in1d(data.SessionId, session_train)] test = data[np.in1d(data.SessionId, session_test)] test = test[np.in1d(test.ItemId, train.ItemId)] tslength = test.groupby('SessionId').size() test = test[np.in1d(test.SessionId, tslength[tslength>=2].index)] print('Full train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train), train.SessionId.nunique(), train.ItemId.nunique())) train.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_full.txt', sep='\t', index=False) print('Test set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(test), test.SessionId.nunique(), test.ItemId.nunique())) test.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_test.txt', sep='\t', index=False) tmax = train.Time.max() session_max_times = train.groupby('SessionId').Time.max() session_train = session_max_times[session_max_times < tmax-86400].index session_valid = session_max_times[session_max_times >= tmax-86400].index train_tr = train[np.in1d(train.SessionId, session_train)] valid = train[np.in1d(train.SessionId, session_valid)] valid = valid[np.in1d(valid.ItemId, train_tr.ItemId)] tslength = valid.groupby('SessionId').size() valid = valid[np.in1d(valid.SessionId, tslength[tslength>=2].index)] print('Train set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(train_tr), train_tr.SessionId.nunique(), train_tr.ItemId.nunique())) train_tr.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_tr.txt', sep='\t', index=False) print('Validation set\n\tEvents: {}\n\tSessions: {}\n\tItems: {}'.format(len(valid), valid.SessionId.nunique(), valid.ItemId.nunique())) valid.to_csv(PATH_TO_PROCESSED_DATA + 'rsc15_train_valid.txt', sep='\t', index=False)<|fim▁end|>
lush(
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: return _fork_i386(parent, child) elif arch == 'amd64': if os in ['linux', 'freebsd']: return _fork_amd64(parent, child) bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def _fork_amd64(parent, child):<|fim▁hole|> push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code def _fork_i386(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code<|fim▁end|>
code = """
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): <|fim_middle|> def _fork_amd64(parent, child): code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code def _fork_i386(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code <|fim▁end|>
"""Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: return _fork_i386(parent, child) elif arch == 'amd64': if os in ['linux', 'freebsd']: return _fork_amd64(parent, child) bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch))
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: return _fork_i386(parent, child) elif arch == 'amd64': if os in ['linux', 'freebsd']: return _fork_amd64(parent, child) bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def _fork_amd64(parent, child): <|fim_middle|> def _fork_i386(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code <|fim▁end|>
code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: return _fork_i386(parent, child) elif arch == 'amd64': if os in ['linux', 'freebsd']: return _fork_amd64(parent, child) bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def _fork_amd64(parent, child): code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code def _fork_i386(parent, child): <|fim_middle|> <|fim▁end|>
code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': <|fim_middle|> elif arch == 'amd64': if os in ['linux', 'freebsd']: return _fork_amd64(parent, child) bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def _fork_amd64(parent, child): code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code def _fork_i386(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code <|fim▁end|>
if os in ['linux', 'freebsd']: return _fork_i386(parent, child)
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: <|fim_middle|> elif arch == 'amd64': if os in ['linux', 'freebsd']: return _fork_amd64(parent, child) bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def _fork_amd64(parent, child): code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code def _fork_i386(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code <|fim▁end|>
return _fork_i386(parent, child)
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: return _fork_i386(parent, child) elif arch == 'amd64': <|fim_middle|> bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def _fork_amd64(parent, child): code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code def _fork_i386(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code <|fim▁end|>
if os in ['linux', 'freebsd']: return _fork_amd64(parent, child)
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: return _fork_i386(parent, child) elif arch == 'amd64': if os in ['linux', 'freebsd']: <|fim_middle|> bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def _fork_amd64(parent, child): code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code def _fork_i386(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code <|fim▁end|>
return _fork_amd64(parent, child)
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: return _fork_i386(parent, child) elif arch == 'amd64': if os in ['linux', 'freebsd']: return _fork_amd64(parent, child) bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def _fork_amd64(parent, child): code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: <|fim_middle|> return code def _fork_i386(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code <|fim▁end|>
code += 'jmp %s\n' % child
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: return _fork_i386(parent, child) elif arch == 'amd64': if os in ['linux', 'freebsd']: return _fork_amd64(parent, child) bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def _fork_amd64(parent, child): code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code def _fork_i386(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: <|fim_middle|> return code <|fim▁end|>
code += 'jmp %s\n' % child
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def <|fim_middle|>(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: return _fork_i386(parent, child) elif arch == 'amd64': if os in ['linux', 'freebsd']: return _fork_amd64(parent, child) bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def _fork_amd64(parent, child): code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code def _fork_i386(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code <|fim▁end|>
fork
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: return _fork_i386(parent, child) elif arch == 'amd64': if os in ['linux', 'freebsd']: return _fork_amd64(parent, child) bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def <|fim_middle|>(parent, child): code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code def _fork_i386(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code <|fim▁end|>
_fork_amd64
<|file_name|>fork.py<|end_file_name|><|fim▁begin|>from pwn.internal.shellcode_helper import * @shellcode_reqs(arch=['i386', 'amd64'], os=['linux', 'freebsd']) def fork(parent, child = None, os = None, arch = None): """Fork this shit.""" if arch == 'i386': if os in ['linux', 'freebsd']: return _fork_i386(parent, child) elif arch == 'amd64': if os in ['linux', 'freebsd']: return _fork_amd64(parent, child) bug('OS/arch combination (%s, %s) was not supported for fork' % (os, arch)) def _fork_amd64(parent, child): code = """ push SYS_fork pop rax syscall test rax, rax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code def <|fim_middle|>(parent, child): code = """ push SYS_fork pop eax int 0x80 test eax, eax jne %s """ % parent if child is not None: code += 'jmp %s\n' % child return code <|fim▁end|>
_fork_i386
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() <|fim▁hole|> def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output<|fim▁end|>
self.data = resp.json() self.created = self.data[-1]['created']
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): <|fim_middle|> <|fim▁end|>
SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): <|fim_middle|> def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output <|fim▁end|>
self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): <|fim_middle|> def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output <|fim▁end|>
if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created']
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): <|fim_middle|> def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output <|fim▁end|>
"""Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): <|fim_middle|> def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output <|fim▁end|>
"""For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): <|fim_middle|> <|fim▁end|>
self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: <|fim_middle|> resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output <|fim▁end|>
return
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: <|fim_middle|> self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output <|fim▁end|>
resp.raise_for_status()
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: <|fim_middle|> else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output <|fim▁end|>
get_item = lambda x: x['apps'][self.app]
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: <|fim_middle|> apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output <|fim▁end|>
get_item = lambda x: x
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: <|fim_middle|> output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output <|fim▁end|>
for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words })
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: <|fim_middle|> item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output <|fim▁end|>
continue
<|file_name|>status.py<|end_file_name|><|fim▁begin|>import requests class Status(object): SKIP_LOCALES = ['en_US'] def __init__(self, url, app=None, highlight=None): self.url = url self.app = app self.highlight = highlight or [] self.data = [] self.created = None def get_data(self): if self.data: return resp = requests.get(self.url) if resp.status_code != 200: resp.raise_for_status() self.data = resp.json() self.created = self.data[-1]['created'] def summary(self): """Generates summary data of today's state""" self.get_data() highlight = self.highlight last_item = self.data[-1] output = {} output['app'] = self.app or 'ALL' data = last_item['locales'] if self.app: get_item = lambda x: x['apps'][self.app] else: get_item = lambda x: x apps = data.items()[0][1]['apps'].keys() apps.sort() output['apps'] = apps items = [item for item in data.items() if item[0] not in highlight] hitems = [item for item in data.items() if item[0] in highlight] highlighted = [] if hitems: for loc, loc_data in sorted(hitems, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: continue item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) highlighted.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['highlighted'] = highlighted locales = [] for loc, loc_data in sorted(items, key=lambda x: -x[1]['percent']): if loc in self.SKIP_LOCALES: <|fim_middle|> item = get_item(loc_data) total = item.get('total', -1) translated = item.get('translated', -1) percent = item.get('percent', -1) untranslated_words = item.get('untranslated_words', -1) locales.append({ 'locale': loc, 'percent': percent, 'total': total, 'translated': translated, 'untranslated': total - translated, 'untranslated_words': untranslated_words }) output['locales'] = locales output['created'] = self.created return output def _mark_movement(self, data): """For each item, converts to a tuple of (movement, item)""" ret = [] prev_day = None for i, day in enumerate(data): if i == 0: ret.append(('', day)) prev_day = day continue if prev_day > day: item = ('down', day) elif prev_day < day: item = ('up', day) else: item = ('equal', day) prev_day = day ret.append(item) return ret def history(self): self.get_data() data = self.data highlight = self.highlight app = self.app # Get a list of the locales we'll iterate through locales = sorted(data[-1]['locales'].keys()) num_days = 14 # Truncate the data to what we want to look at data = data[-num_days:] if app: get_data = lambda x: x['apps'][app]['percent'] else: get_data = lambda x: x['percent'] hlocales = [loc for loc in locales if loc in highlight] locales = [loc for loc in locales if loc not in highlight] output = {} output['app'] = self.app or 'All' output['headers'] = [item['created'] for item in data] output['highlighted'] = sorted( (loc, self._mark_movement(get_data(day['locales'][loc]) for day in data)) for loc in hlocales ) output['locales'] = sorted( (loc, self._mark_movement(get_data(day['locales'].get(loc, {'percent': 0.0})) for day in data)) for loc in locales ) output['created'] = self.created return output <|fim▁end|>
continue