rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
short_flags ="f:t:k:K:o:n:m:hV"
short_flags ="sf:t:k:K:o:n:N:m:hV"
def main(): """Main function """ global options long_flags =["pdffile=", "textfile=" "thesaurus=","ontology=", "output=","nkeywords=", "mode=", "help", "version"] short_flags ="f:t:k:K:o:n:m:hV" format_string = "%Y-%m-%d %H:%M:%S" outwords = 15 input_file = "" dict_file = "" output = 1 mode = 1 temp_text = tmpdir + '/...
outwords = 15
standalone = False nkeywords = 70 Nkeywords = 25
def main(): """Main function """ global options long_flags =["pdffile=", "textfile=" "thesaurus=","ontology=", "output=","nkeywords=", "mode=", "help", "version"] short_flags ="f:t:k:K:o:n:m:hV" format_string = "%Y-%m-%d %H:%M:%S" outwords = 15 input_file = "" dict_file = "" output = 1 mode = 1 temp_text = tmpdir + '/...
temp_text = tmpdir + '/bibclassify.pdftotext.' + str(os.getpid())
def main(): """Main function """ global options long_flags =["pdffile=", "textfile=" "thesaurus=","ontology=", "output=","nkeywords=", "mode=", "help", "version"] short_flags ="f:t:k:K:o:n:m:hV" format_string = "%Y-%m-%d %H:%M:%S" outwords = 15 input_file = "" dict_file = "" output = 1 mode = 1 temp_text = tmpdir + '/...
print "Version 0.1"
print bibclassify_engine_version
def main(): """Main function """ global options long_flags =["pdffile=", "textfile=" "thesaurus=","ontology=", "output=","nkeywords=", "mode=", "help", "version"] short_flags ="f:t:k:K:o:n:m:hV" format_string = "%Y-%m-%d %H:%M:%S" outwords = 15 input_file = "" dict_file = "" output = 1 mode = 1 temp_text = tmpdir + '/...
cmd = "%s -nopgbrk -q " % pdftotext + opt[1] + " " + temp_text
cmd = "%s " % pdftotext + opt[1] + " " + temp_text
def main(): """Main function """ global options long_flags =["pdffile=", "textfile=" "thesaurus=","ontology=", "output=","nkeywords=", "mode=", "help", "version"] short_flags ="f:t:k:K:o:n:m:hV" format_string = "%Y-%m-%d %H:%M:%S" outwords = 15 input_file = "" dict_file = "" output = 1 mode = 1 temp_text = tmpdir + '/...
outwords = num
nkeywords = num
def main(): """Main function """ global options long_flags =["pdffile=", "textfile=" "thesaurus=","ontology=", "output=","nkeywords=", "mode=", "help", "version"] short_flags ="f:t:k:K:o:n:m:hV" format_string = "%Y-%m-%d %H:%M:%S" outwords = 15 input_file = "" dict_file = "" output = 1 mode = 1 temp_text = tmpdir + '/...
write_message("Number of keywords (-nkeywords) must be an integer higher than 1. Using default value of 15...")
write_message("Number of keywords for processing (-nkeywords) must be an integer higher than 1. Using default value of 70...")
def main(): """Main function """ global options long_flags =["pdffile=", "textfile=" "thesaurus=","ontology=", "output=","nkeywords=", "mode=", "help", "version"] short_flags ="f:t:k:K:o:n:m:hV" format_string = "%Y-%m-%d %H:%M:%S" outwords = 15 input_file = "" dict_file = "" output = 1 mode = 1 temp_text = tmpdir + '/...
write_message("Number of keywords (-n) must be an integer. Using default value of 15...")
write_message("Number of keywords for processing (-n) must be an integer. Using default value of 70...") elif opt[0] in [ "-N", "--Nkeywords" ]: try: num = int(opt[1]) if num>1: Nkeywords = num else: write_message("Number of keywords (-Nkeywords) must be an integer higher than 1. Using default value of 25...") except...
def main(): """Main function """ global options long_flags =["pdffile=", "textfile=" "thesaurus=","ontology=", "output=","nkeywords=", "mode=", "help", "version"] short_flags ="f:t:k:K:o:n:m:hV" format_string = "%Y-%m-%d %H:%M:%S" outwords = 15 input_file = "" dict_file = "" output = 1 mode = 1 temp_text = tmpdir + '/...
outcome = generate_keywords_rdf(input_file, dict_file, output, outwords, mode)
outcome = generate_keywords_rdf(input_file, dict_file, output, nkeywords, Nkeywords, mode)
def main(): """Main function """ global options long_flags =["pdffile=", "textfile=" "thesaurus=","ontology=", "output=","nkeywords=", "mode=", "help", "version"] short_flags ="f:t:k:K:o:n:m:hV" format_string = "%Y-%m-%d %H:%M:%S" outwords = 15 input_file = "" dict_file = "" output = 1 mode = 1 temp_text = tmpdir + '/...
if outwords > len(outcome): outwords = len(outcome)
if nkeywords > len(outcome): nkeywords = len(outcome)
def main(): """Main function """ global options long_flags =["pdffile=", "textfile=" "thesaurus=","ontology=", "output=","nkeywords=", "mode=", "help", "version"] short_flags ="f:t:k:K:o:n:m:hV" format_string = "%Y-%m-%d %H:%M:%S" outwords = 15 input_file = "" dict_file = "" output = 1 mode = 1 temp_text = tmpdir + '/...
for i in range(outwords):
for i in range(nkeywords):
def main(): """Main function """ global options long_flags =["pdffile=", "textfile=" "thesaurus=","ontology=", "output=","nkeywords=", "mode=", "help", "version"] short_flags ="f:t:k:K:o:n:m:hV" format_string = "%Y-%m-%d %H:%M:%S" outwords = 15 input_file = "" dict_file = "" output = 1 mode = 1 temp_text = tmpdir + '/...
if string.find(f+":"+argd[px], p) > -1: argd[px] = string.replace(f+":"+argd[px], f+":"+p, term)
if string.find(argd[px], f+":"+p) > -1: argd[px] = string.replace(argd[px], f+":"+p, f+":"+term)
def create_nearest_terms_box(urlargd, p, f, t='w', n=5, ln=cdslang, intro_text_p=True): """Return text box containing list of 'n' nearest terms above/below 'p' for the field 'f' for matching type 't' (words/phrases) in language 'ln'. Propose new searches according to `urlargs' with the new words. If `intro_text_p' is t...
<dd>For documentation, take a look at the <a href="%s/admin/websearch/websearchadminguide.html">Websearch Admin Guide</a>.</dd>
<dd>For documentation, take a look at the <a href="%s/admin/websearch/guide.html">Websearch Admin Guide</a>.</dd>
def perform_index(colID=1, ln=cdslang, mtype='', content='', confirm=0): subtitle = "Overview" colID = int(colID) col_dict = dict(get_current_name('', ln, get_col_mainnametype(), "collection")) fin_output = "" output = "" if mtype == "perform_addcollection": fin_output += content else: fin_output += perform_addcollec...
warnings.append(_("Group %s does not exist.")% (group_name))
warnings.append(_("Group %s does not exist.")% (cgi.escape(group_name)))
def strip_spaces(str): """suppress spaces before and after x (str)""" return str.strip()
warnings.append(_("User %s does not exist.")% (user_nick))
warnings.append(_("User %s does not exist.")% (cgi.escape(user_nick)))
def strip_spaces(str): """suppress spaces before and after x (str)""" return str.strip()
</tr>""" %(name, description, edit_link, members_link)
</tr>""" % (cgi.escape(name), cgi.escape(description), edit_link, members_link)
def tmpl_display_admin_group(self, groups, ln=cdslang): """ Display the groups the user is admin of. Parameters:
</tr>""" %(name, description)
</tr>""" % (cgi.escape(name), cgi.escape(description))
def tmpl_display_member_group(self, groups, ln=cdslang): """ Display the groups the user is member of. Parameters: - 'ln' *string* - The language to display the interface in - 'groups' *list* - All the group the user is member of """ _ = gettext_set_language(ln) group_text = self.tmpl_group_table_title(img="/img/webb...
label = _('Edit group %s') % group_name
label = _('Edit group %s') % cgi.escape(group_name)
def tmpl_display_input_group_info(self, group_name, group_description, join_policy, act_type="create", grpID="", warnings=[], ln=cdslang): """ Display group data when creating or updating a group: Name, description, join_policy. Parameters: - 'ln' *string* - The language to display the interface in - 'group_name' *stri...
'group_name': group_name, 'group_description': group_description,
'group_name': cgi.escape(group_name, 1), 'group_description': cgi.escape(group_description, 1),
def tmpl_display_input_group_info(self, group_name, group_description, join_policy, act_type="create", grpID="", warnings=[], ln=cdslang): """ Display group data when creating or updating a group: Name, description, join_policy. Parameters: - 'ln' *string* - The language to display the interface in - 'group_name' *stri...
'group_name': group_name,
'group_name': cgi.escape(group_name, 1),
def tmpl_display_input_join_group(self, group_list, group_name, group_from_search, search, warnings=[], ln=cdslang):
filename = re.sub("\..*","",os.path.basename(fullpath))
filename = re.sub("\..*","",re.sub(r".*[\\/:]", "", fullpath))
def addNewFile(self,fullpath,type="Main"): filename = re.sub("\..*","",os.path.basename(fullpath)) bibdoc = self.addBibDoc(type,filename) if bibdoc != None: bibdoc.addFilesNewVersion(files=[fullpath]) return bibdoc return None
docname = re.sub("\..*","",os.path.basename(fullpath))
docname = re.sub("\..*","",re.sub(r".*[\\/:]", "", fullpath))
def addNewVersion(self,fullpath,bibdocid): bibdoc = self.getBibDoc(bibdocid) if bibdoc != None: bibdoc.addFilesNewVersion(files=[fullpath]) docname = re.sub("\..*","",os.path.basename(fullpath)) if docname != bibdoc.getDocName(): while docname in self.getBibDocNames(bibdoc.getType()): match = re.match("(.*_)([^_]*)",do...
filename = os.path.basename(file)
filename = re.sub(r".*[\\/:]", "", file)
def addFilesNewVersion(self,files=[]): """add a new version of a file to an archive""" latestVersion = self.getLatestVersion() if latestVersion == "0": myversion = "1" else: myversion = str(int(latestVersion)+1) for file in files: if os.path.exists(file): filename = os.path.basename(file) shutil.copy(file,"%s/%s;%s" % ...
filename = os.path.basename(file)
filename = re.sub(r".*[\\/:]", "", file)
def addFilesNewFormat(self,files=[],version=""): """add a new format of a file to an archive""" if version == "": version = self.getLatestVersion() for file in files: if os.path.exists(file): filename = os.path.basename(file) shutil.copy(file,"%s/%s;%s" % (self.basedir,filename,version)) self.BuildFileList()
filename = re.sub("\..*","",os.path.basename(file))
filename = re.sub("\..*","",re.sub(r".*[\\/:]", "", file))
def addIcon(self,file): """link an icon with the bibdoc object""" #first check if an icon already exists existingIcon = self.getIcon() if existingIcon != None: existingIcon.delete() #then add the new one filename = re.sub("\..*","",os.path.basename(file)) newicon = BibDoc(type='Icon',docname=filename) if newicon != Non...
fromaddr = "From:cds.support@cern.ch"
fromaddr = "From:cds.alert@cdsware.cern.ch"
def send_email(req,p_email=None): uid = webuser.getUid(req) passw = webuser.givePassword(p_email) if passw == -999: eMsg = "The entered e-mail address doesn't exist in the database" return page(title="Your Account", body=webaccount.perform_emailMessage(eMsg), navtrail="""<a class="navtrail" href="%s/youraccount.py/di...
from alert_engine import send_email
from alert_engine import send_email, forge_email body = forge_email(from_addr, to_addr, subject, body)
def perform_request_report(comID): """ Report a comment/review for inappropriate content. Will send an email to the administrator if number of reports is a multiple of config.py/cfg_comment_nb_reports_before_send_email_to_admin @param comID: comment id @return integer 1 if successful, integer 0 if not """ #FIXME should...
query1 = "SELECT * FROM cmtRECORDCOMMENT WHERE id=%s"
query1 = "SELECT id, id_bibrec, id_user, body, date_creation, star_score, nb_votes_yes, nb_votes_total, title, nb_abuse_reports FROM cmtRECORDCOMMENT WHERE id=%s"
def query_get_comment(comID): """ Get all fields of a comment @param comID: comment id @return tuple (comID, id_bibrec, id_user, body, date_creation, star_score, nb_votes_yes, nb_votes_total, title, nb_abuse_reports) if none found return () """ query1 = "SELECT * FROM cmtRECORDCOMMENT WHERE id=%s" params1 = (comID,) re...
def get_first_comments_or_remarks(recID=-1, ln=cdslang, nb='all', voted=-1, reported=-1):
def get_first_comments_or_remarks(recID=-1, ln=cdslang, nb_comments='all', nb_reviews='all', voted=-1, reported=-1):
def get_first_comments_or_remarks(recID=-1, ln=cdslang, nb='all', voted=-1, reported=-1): """ Gets nb number comments/reviews or remarks. In the case of comments, will get both comments and reviews Comments and remarks sorted by most recent date, reviews sorted by highest helpful score @param recID: record id @param ln...
if type(nb) is int and nb < len(res_reviews): first_res_reviews = res_reviews[:nb]
if type(nb_reviews) is int and nb_reviews < len(res_reviews): first_res_reviews = res_reviews[:nb_reviews]
def get_first_comments_or_remarks(recID=-1, ln=cdslang, nb='all', voted=-1, reported=-1): """ Gets nb number comments/reviews or remarks. In the case of comments, will get both comments and reviews Comments and remarks sorted by most recent date, reviews sorted by highest helpful score @param recID: record id @param ln...
if type(nb) is int and nb < len(res_comments): first_res_comments = res_comments[:nb]
if type(nb_comments) is int and nb_comments < len(res_comments): first_res_comments = res_comments[:nb_comments]
def get_first_comments_or_remarks(recID=-1, ln=cdslang, nb='all', voted=-1, reported=-1): """ Gets nb number comments/reviews or remarks. In the case of comments, will get both comments and reviews Comments and remarks sorted by most recent date, reviews sorted by highest helpful score @param recID: record id @param ln...
Record = %(record_details)s
Record = <!-- start record details --> %(record_details)s <!-- end record details -->
def notify_admin_of_new_comment(comID): """ Sends an email to the admin with details regarding comment with ID = comID """ comment = query_get_comment(comID) if len(comment) > 0: (comID2, id_bibrec, id_user, body, date_creation, star_score, nb_votes_yes, nb_votes_total, title, nb_abuse_reports) = comment else: return u...
from alert_engine import send_email
from alert_engine import send_email, forge_email out = forge_email(from_addr, to_addr, subject, out)
def notify_admin_of_new_comment(comID): """ Sends an email to the admin with details regarding comment with ID = comID """ comment = query_get_comment(comID) if len(comment) > 0: (comID2, id_bibrec, id_user, body, date_creation, star_score, nb_votes_yes, nb_votes_total, title, nb_abuse_reports) = comment else: return u...
"Failing test for sourceforge bug 1452832"
def testBug1452832(self): "Failing test for sourceforge bug 1452832" self.app1.UntitledNotepad.MenuSelect("Edit -> Select All") typetext(self.app1, "some text") copytext(self.app1)
test_module = __import__(test_name.lower())
test_module = __import__(test_name.lower(), globals(), locals())
def __init_tests(): "Initialize each test by loading it and then register it" global _registered for test_name in _test_names: test_module = __import__(test_name.lower()) # class name is the test name + "Test" test_class = getattr(test_module, test_name + "Test") _registered[test_name] = test_class
_package_path = os.path.split(__file__)[0] sys.path.append(_package_path) del _package_path
def __init_tests(): "Initialize each test by loading it and then register it" global _registered for test_name in _test_names: test_module = __import__(test_name.lower()) # class name is the test name + "Test" test_class = getattr(test_module, test_name + "Test") _registered[test_name] = test_class
sys.path = sys.path[:-1] def _unittests(): "Some unit tests" pass if __name__ == "__main__": _unittests()
def __init_tests(): "Initialize each test by loading it and then register it" global _registered for test_name in _test_names: test_module = __import__(test_name.lower()) # class name is the test name + "Test" test_class = getattr(test_module, test_name + "Test") _registered[test_name] = test_class
'PartWidths',
'PartRightEdges',
def __init__(self, hwnd): "Initialise the instance" super(StatusBarWrapper, self).__init__(hwnd)
def NumBands(self):
self.writable_props.extend(['BandCount']) def BandCount(self):
def __init__(self, hwnd): "Initialise the instance" super(ReBarWrapper, self).__init__(hwnd)
for i in range(0, self.NumBands()):
for i in range(0, self.BandCount()):
def Texts(self): "Return the texts of the Rebar" texts = [self.Text()] for i in range(0, self.NumBands()): band = self.GetBand(i) texts.append(band.text)
def GetProperties(self): "Return the properties for the ReBar" props = HwndWrapper.HwndWrapper.GetProperties(self) props['BandCount'] = self.NumBands()
def Texts(self): "Return the texts of the Rebar" texts = [self.Text()] for i in range(0, self.NumBands()): band = self.GetBand(i) texts.append(band.text)
props['Class'] = self.Class() props['FriendlyClassName'] = self.FriendlyClassName() props['Texts'] = self.Texts() props['Style'] = self.Style() props['ExStyle'] = self.ExStyle() props['ControlID'] = self.ControlID() props['UserData'] = self.UserData() props['ContextHelpID'] = self.ContextHelpID() props['Fonts'] = ...
for propname in self.writable_props: props[propname] = getattr(self, propname)()
def GetProperties(self): "Return the properties of the control as a dictionary" props = {}
"Return a PIL image of the dialog"
"Return a PIL image of the control"
def CaptureAsImage(self): "Return a PIL image of the dialog" if not (self.Rectangle().width() and self.Rectangle().height()): return None
"Verify that the control is visible and enabled"
def VerifyActionable(self): "Verify that the control is visible and enabled" win32functions.WaitGuiThreadIdle(self) self.VerifyVisible() self.VerifyEnabled()
"Verify that the control is enabled"
def VerifyEnabled(self): "Verify that the control is enabled"
if not self.friendlyclassname == "Dialog": if not self.Parent().IsEnabled(): raise ControlNotEnabled()
if self.Parent() and not self.Parent().IsEnabled(): raise ControlNotEnabled()
def VerifyEnabled(self): "Verify that the control is enabled"
"Verify that the control is visible"
def VerifyVisible(self): "Verify that the control is visible"
if not self.friendlyclassname == "Dialog": if not self.Parent().IsVisible(): raise ControlNotVisible()
if self.Parent() and not self.Parent().IsVisible(): raise ControlNotVisible()
def VerifyVisible(self): "Verify that the control is visible"
self, button = "left", pressed = "", coords = (0, 0), double = True):
self, button = "left", pressed = "", coords = (0, 0)):
def DoubleClick( self, button = "left", pressed = "", coords = (0, 0), double = True): "Perform a double click action" _perform_click(self, button, pressed, coords, double) return self
_perform_click(self, button, pressed, coords, double)
_perform_click(self, button, pressed, coords, double = True)
def DoubleClick( self, button = "left", pressed = "", coords = (0, 0), double = True): "Perform a double click action" _perform_click(self, button, pressed, coords, double) return self
self, button = "right", pressed = "", coords = (0, 0), double = True):
self, pressed = "", coords = (0, 0)):
def RightClick( self, button = "right", pressed = "", coords = (0, 0), double = True): "Perform a right click action" _perform_click(self, button, pressed, coords, double) return self
_perform_click(self, button, pressed, coords, double)
_perform_click(self, "right", "right " + pressed, coords, button_up = False) _perform_click(self, "right", pressed, coords, button_down = False)
def RightClick( self, button = "right", pressed = "", coords = (0, 0), double = True): "Perform a right click action" _perform_click(self, button, pressed, coords, double) return self
try: process_id = process.ProcessID except AttributeError: process_id = process windows = [win for win in windows if process == process_id]
windows = [win for win in windows if handleprops.processid(win) == process]
def find_windows(class_name = None, class_name_re = None, parent = None, process = None, title = None, title_re = None, top_level_only = True, visible_only = True, enabled_only = True, #best_match = None ): """Find windows based on criteria passed in Possible values are: class_name Windows with this window class clas...
ident = self.ItemTexts().index(ident) -1
ident = self.ItemTexts().index(ident)
def _get_item_index(self, ident): if isinstance(ident, (int, long)):
index = self._get_item_index(i)
index = self._get_item_index(item)
def Select(self, item): """Select the ListBox item
ctrl.Class(), ctrl.WindowText(), str(ctrl.Rectangle()))
ctrl.Class(), ctrl.WindowText().encode("unicode-escape"), str(ctrl.Rectangle()))
def PrintControlIdentifiers(self): """Prints the 'identifiers'
from datetime import datetime today = datetime.today() date_string = "%d/%d/%d" % (today.month, today.day, today.year) self.ctrl.Select(date_string)
item_to_select = self.ctrl.Texts()[2] self.ctrl.Select(item_to_select)
def testSelect(self): self.ctrl.Select(5) self.assertEquals(self.ctrl.SelectedIndices(), [5,])
hPen = CreatePen(PS_SOLID, 2, colour)
hPen = win32functions.CreatePen(PS_SOLID, 2, colour)
def draw_outline(ctrl, colour = 'green', thickness = 2, fill = BS_NULL, rect = None): colours = { "green" : 0x00ff00, "blue" : 0xff0000, "red" : 0x0000ff, } # if it's a known colour if colour in colours: colour = colours[colour] if not rect: rect = ctrl.Rectangle # create the pen(outline) hPen = CreatePen(PS_SOLID,...
brush = LOGBRUSH()
brush = win32structures.LOGBRUSH()
def draw_outline(ctrl, colour = 'green', thickness = 2, fill = BS_NULL, rect = None): colours = { "green" : 0x00ff00, "blue" : 0xff0000, "red" : 0x0000ff, } # if it's a known colour if colour in colours: colour = colours[colour] if not rect: rect = ctrl.Rectangle # create the pen(outline) hPen = CreatePen(PS_SOLID,...
hBrush = CreateBrushIndirect(byref(brush))
hBrush = win32functions.CreateBrushIndirect(byref(brush))
def draw_outline(ctrl, colour = 'green', thickness = 2, fill = BS_NULL, rect = None): colours = { "green" : 0x00ff00, "blue" : 0xff0000, "red" : 0x0000ff, } # if it's a known colour if colour in colours: colour = colours[colour] if not rect: rect = ctrl.Rectangle # create the pen(outline) hPen = CreatePen(PS_SOLID,...
dc = CreateDC(u"DISPLAY", None, None, None )
dc = win32functions.CreateDC(u"DISPLAY", None, None, None )
def draw_outline(ctrl, colour = 'green', thickness = 2, fill = BS_NULL, rect = None): colours = { "green" : 0x00ff00, "blue" : 0xff0000, "red" : 0x0000ff, } # if it's a known colour if colour in colours: colour = colours[colour] if not rect: rect = ctrl.Rectangle # create the pen(outline) hPen = CreatePen(PS_SOLID,...
SelectObject(dc, hBrush) SelectObject(dc, hPen)
win32functions.SelectObject(dc, hBrush) win32functions.SelectObject(dc, hPen)
def draw_outline(ctrl, colour = 'green', thickness = 2, fill = BS_NULL, rect = None): colours = { "green" : 0x00ff00, "blue" : 0xff0000, "red" : 0x0000ff, } # if it's a known colour if colour in colours: colour = colours[colour] if not rect: rect = ctrl.Rectangle # create the pen(outline) hPen = CreatePen(PS_SOLID,...
DeleteObject(hBrush) DeleteObject(hPen)
win32functions.DeleteObject(hBrush) win32functions.DeleteObject(hPen)
def draw_outline(ctrl, colour = 'green', thickness = 2, fill = BS_NULL, rect = None): colours = { "green" : 0x00ff00, "blue" : 0xff0000, "red" : 0x0000ff, } # if it's a known colour if colour in colours: colour = colours[colour] if not rect: rect = ctrl.Rectangle # create the pen(outline) hPen = CreatePen(PS_SOLID,...
DeleteDC(dc)
win32functions.DeleteDC(dc) def run_tests_action(ctrl, tests_to_run = None): controls = [ctrl] controls.extend(ctrl.Children) return tests.run_tests(controls, tests_to_run)
def draw_outline(ctrl, colour = 'green', thickness = 2, fill = BS_NULL, rect = None): colours = { "green" : 0x00ff00, "blue" : 0xff0000, "red" : 0x0000ff, } # if it's a known colour if colour in colours: colour = colours[colour] if not rect: rect = ctrl.Rectangle # create the pen(outline) hPen = CreatePen(PS_SOLID,...
def MenuInfo(self): "Get info" menu = self.MenuHandle() info = win32structures.MENUINFO() info.cbSize = ctypes.sizeof(info) info.fMask = win32defines.MIM_STYLE print "sdfdsf", win32functions.GetMenuInfo(menu, ctypes.byref(info)) print self.Parent() print self.Owner() print info print info.dwStyle & win32defines.MNS_...
def _menu_handle(self):
def MenuInfo(self): "Get info" menu = self.MenuHandle()
def MenuItems(self): "return the menu items from teh popup" menu_handle = self.MenuHandle() self.SendMessage(win32defines.WM_INITMENU, menu_handle) return HwndWrapper._GetMenuItems(menu_handle, self) def MenuSelect(self, path, ctrl, items=None): "Select a popup menu item" if not items: items = self.MenuItems() ...
def MenuItems(self): "return the menu items from teh popup" menu_handle = self.MenuHandle()
ratio = ratio_calc.real_quick_ratio() if ratio * ratio_offset > find_best_control_match_cutoff:
ratio = ratio_calc.real_quick_ratio() * ratio_offset if ratio >= find_best_control_match_cutoff:
def FindBestMatches( self, search_text, clean = False, ignore_case = False):
if ratio * ratio_offset > find_best_control_match_cutoff: ratio = ratio_calc.ratio()
if ratio >= find_best_control_match_cutoff: ratio = ratio_calc.ratio() * ratio_offset
def FindBestMatches( self, search_text, clean = False, ignore_case = False):
if ratios[text_] > best_ratio:
if ratios[text_] > best_ratio and \ ratios[text_] >= find_best_control_match_cutoff:
def FindBestMatches( self, search_text, clean = False, ignore_case = False):
best_ratio *= ratio_offset
def FindBestMatches( self, search_text, clean = False, ignore_case = False):
def GetNonTextControlName(ctrl, text_ctrls):
def GetNonTextControlName(ctrl, controls):
def GetNonTextControlName(ctrl, text_ctrls): """return the name for this control by finding the closest text control above and to its left""" name = '' closest = distance_cuttoff # now for each of the visible text controls for text_ctrl in text_ctrls: # get aliases to the control rectangles text_r = text_ctrl.Rectang...
name = ''
names = [] ctrl_index = controls.index(ctrl) if ctrl_index != 0: prev_ctrl = controls[ctrl_index-1] if prev_ctrl.FriendlyClassName() == "Static" and \ prev_ctrl.IsVisible() and _clean_text(prev_ctrl.WindowText()) and \ IsAboveOrToLeft(ctrl, prev_ctrl): names.append( _clean_text(prev_ctrl.WindowText()) + ctrl.Friend...
def GetNonTextControlName(ctrl, text_ctrls): """return the name for this control by finding the closest text control above and to its left""" name = '' closest = distance_cuttoff # now for each of the visible text controls for text_ctrl in text_ctrls: # get aliases to the control rectangles text_r = text_ctrl.Rectang...
name = _clean_text(text_ctrl.WindowText()) + ctrl.FriendlyClassName() return name def get_control_names(control, visible_text_controls):
best_name = _clean_text( text_ctrl.WindowText()) + ctrl.FriendlyClassName() names.append(best_name) return names def get_control_names(control, allcontrols):
def GetNonTextControlName(ctrl, text_ctrls): """return the name for this control by finding the closest text control above and to its left""" name = '' closest = distance_cuttoff # now for each of the visible text controls for text_ctrl in text_ctrls: # get aliases to the control rectangles text_r = text_ctrl.Rectang...
name = GetNonTextControlName(control, visible_text_controls)
non_text_names = GetNonTextControlName(control, allcontrols)
def get_control_names(control, visible_text_controls): "Returns a list of names for this control" names = [] # if it has a reference control - then use that #if hasattr(control, 'ref') and control.ref: # control = control.ref # Add the control based on it's friendly class name names.append(control.FriendlyClassNam...
if name: names.append(name)
if non_text_names: names.extend(non_text_names)
def get_control_names(control, visible_text_controls): "Returns a list of names for this control" names = [] # if it has a reference control - then use that #if hasattr(control, 'ref') and control.ref: # control = control.ref # Add the control based on it's friendly class name names.append(control.FriendlyClassNam...
visible_text_ctrls = [ctrl for ctrl in controls if ctrl.IsVisible() and _clean_text(ctrl.WindowText())]
def find_best_control_matches(search_text, controls): """Returns the control that is the the best match to search_text This is slightly differnt from find_best_match in that it builds up the list of text items to search through using information from each control. So for example for there is an OK, Button then the fol...
ctrl_names = get_control_names(ctrl, visible_text_ctrls)
ctrl_names = get_control_names(ctrl, controls)
def find_best_control_matches(search_text, controls): """Returns the control that is the the best match to search_text This is slightly differnt from find_best_match in that it builds up the list of text items to search through using information from each control. So for example for there is an OK, Button then the fol...
print test_name
def run_tests(controls, tests_to_run = None, test_visible_only = True): # allow either a string or list to be passed try: tests_to_run = tests_to_run.split() except AttributeError: pass # if no tests specified run them all if tests_to_run is None: tests_to_run = registered.keys() # Filter out hidden controls if requ...
ctrl.DrawOutline()
def print_bugs(bugs): for (ctrls, info, bType, inRef) in bugs: print "BugType:", bType, for i in info: print i, info[i], print for i, ctrl in enumerate(ctrls): print '\t"%s" "%s" (%d %d %d %d) Vis: %d'% ( ctrl.Text, ctrl.FriendlyClassName, ctrl.Rectangle.left, ctrl.Rectangle.top, ctrl.Rectangle.right, ctrl.Rectangl...
try: ctrl.DrawOutline() except (AttributeError, KeyError), e: pass
def print_bugs(bugs): for (ctrls, info, bType, inRef) in bugs: print "BugType:", bType, for i in info: print i, info[i], print for i, ctrl in enumerate(ctrls): print '\t"%s" "%s" (%d %d %d %d) Vis: %d'% ( ctrl.Text, ctrl.FriendlyClassName, ctrl.Rectangle.left, ctrl.Rectangle.top, ctrl.Rectangle.right, ctrl.Rectangl...
self.process = controls.WrapHandle(handle, True).ProcessID
self.process = Process(controls.WrapHandle(handle, True).ProcessID)
def _connect(self, **kwargs): "Connects to an already running process" connected = False if 'process' in kwargs: self.process = Process(kwargs['process']) connected = True
windows = [win for win in windows if win.Parent == parent]
windows = [win for win in windows if handleprops.parent(win) == parent]
def find_windows(class_name = None, class_name_re = None, parent = None, process = None, title = None, title_re = None, top_level_only = True, visible_only = True, enabled_only = True, #best_match = None ): """Find windows based on criteria passed in Possible values are: class_name Windows with this window class clas...
if parent: windows = enum_child_windows(parent) else:
if not parent:
def find_windows(class_name = None, class_name_re = None, parent = None, process = None, title = None, title_re = None, top_level_only = True, visible_only = True, enabled_only = True, #best_match = None ): """Find windows based on criteria passed in Possible values are: class_name Windows with this window class clas...
windows = enum_child_windows(parent) windows = [win for win in windows if handleprops.parent(win) == parent]
def find_windows(class_name = None, class_name_re = None, parent = None, process = None, title = None, title_re = None, top_level_only = True, visible_only = True, enabled_only = True, #best_match = None ): """Find windows based on criteria passed in Possible values are: class_name Windows with this window class clas...
if len(self.criteria) == 2: ctrl = _resolve_control( self.criteria, window_find_timeout, window_retry_interval) if hasattr(ctrl, '__getitem__'): return ctrl[key] else: message = "The control does not have a __getitem__ method " \ "for item access (i.e. ctrl[key]) so maybe you have " \ "requested this in error?" raise...
def __getitem__(self, key): """Allow access to dialogs/controls through item access
self.WaitReady(
self.Wait("ready",
def __getattr__(self, attr): """Attribute access for this class
def Wait(self, *args, **kwargs): """Wait for the window to be in any of the following states: 'exists' 'visible' 'enabled' 'ready' e.g. self.Dlg.Wait("exists", "enabled", "visible", "ready") 'exists' means that the window is a valid handle 'visible' means that the window is not hidden 'enabled' means that the window...
def Wait(self, wait_for, timeout = window_find_timeout, wait_interval = window_retry_interval): """Wait for the window to be in a particular state :wait_for: The state to wait for the window to be in. It can be any of the following states * 'exists' means that the window is a valid handle * 'visible' means that the ...
def Wait(self, *args, **kwargs): """Wait for the window to be in any of the following states:
args = [arg.lower().strip() for arg in args]
waitfor = wait_for.lower()
def Wait(self, *args, **kwargs): """Wait for the window to be in any of the following states:
if 'exists' in args:
if 'exists' in waitfor:
def Wait(self, *args, **kwargs): """Wait for the window to be in any of the following states:
if 'visible' in args:
if 'visible' in waitfor:
def Wait(self, *args, **kwargs): """Wait for the window to be in any of the following states:
if 'enabled' in args:
if 'enabled' in waitfor:
def Wait(self, *args, **kwargs): """Wait for the window to be in any of the following states:
if 'ready' in args:
if 'ready' in waitfor:
def Wait(self, *args, **kwargs): """Wait for the window to be in any of the following states:
timeout = kwargs.get('timeout', window_find_timeout) wait_interval = kwargs.get( 'wait_interval', window_retry_interval)
def Wait(self, *args, **kwargs): """Wait for the window to be in any of the following states:
def WaitNot(self, *args, **kwargs): """Wait for the window to not be in any of the following states: 'exists' 'visible' 'enabled' 'ready' e.g. self.Dlg.Wait("exists", "enabled", "visible", "ready") 'exists' means that the window is a valid handle 'visible' means that the window is not hidden 'enabled' means that the...
def WaitNot(self, wait_for_not, timeout = window_find_timeout, wait_interval = window_retry_interval): """Wait for the window to not be in a particular state :wait_for: The state to wait for the window to not be in. It can be any of the following states * 'exists' means that the window is a valid handle * 'visible' ...
def WaitNot(self, *args, **kwargs): """Wait for the window to not be in any of the following states:
timeout = kwargs.get('timeout', window_find_timeout) wait_interval = kwargs.get( 'wait_interval', window_retry_interval) waited = 0
wait_for_not = wait_for_not.lower() start = time.time()
def WaitNot(self, *args, **kwargs): """Wait for the window to not be in any of the following states:
ctrl = _resolve_control(waitnot_criteria) if 'exists' in args:
ctrl = _resolve_control(waitnot_criteria, 0, .01) matched = True if 'exists' in wait_for_not:
def WaitNot(self, *args, **kwargs): """Wait for the window to not be in any of the following states:
continue matched = True if 'ready' in args:
matched = False if 'ready' in wait_for_not:
def WaitNot(self, *args, **kwargs): """Wait for the window to not be in any of the following states:
if 'enabled' in args:
if 'enabled' in wait_for_not:
def WaitNot(self, *args, **kwargs): """Wait for the window to not be in any of the following states:
if 'visible' in args:
if 'visible' in wait_for_not:
def WaitNot(self, *args, **kwargs): """Wait for the window to not be in any of the following states:
if waited >= timeout: break time.sleep(wait_interval) waited += wait_interval
waited = time.time() - start if waited < timeout: time.sleep(min(wait_interval, timeout - waited)) else: raise RuntimeError( "Timed out while waiting for window to not be in " "'%s' state"% ( "', '".join( wait_for_not.split() ) ) )
def WaitNot(self, *args, **kwargs): """Wait for the window to not be in any of the following states: