import re
###################################################
# These regular expressions were created with Kodos 
#                                                 
# http://kodos.sourceforge.net
#
###################################################

#PROJECTS_FROM_PROFILE = re.compile("""<A href="/projects/(?P<unixname>.*)/">(?P<projectname>.*)</A>""")

#GROUP_ID_FROM_SUMMARY = re.compile("""href="/project/admin/\?group_id=(?P<groupid>\d*)">""")

PACKAGE_FORMS = re.compile('''<FORM ACTION="/project/admin/editpackages.php" METHOD="POST">(?P<data>.*?)</FORM>''', re.DOTALL)

PACKAGES_FULL_ACCESS = re.compile('''NAME="package_id"\s*VALUE="(?P<packageid>\d*)".*?NAME="package_name"\s*VALUE="(?P<packagename>.*?)".*?selected>(?P<status>Hidden|Active)''', re.DOTALL | re.IGNORECASE)

######PACKAGES_LIMITED_ACCESS = re.compile('''NAME="package_id"\s*VALUE="(?P<packageid>\d*)".*?\[Add Release\].*?<TD><FONT SIZE="-1">(?P<packagename>.*?)</TD>.*?selected>(?P<status>Hidden|Active)''', re.DOTALL | re.IGNORECASE)

######PACKAGES_LIMITED_ACCESS = re.compile('''NAME="package_id"\s*VALUE="(?P<packageid>\d*)".*?\[Add Release\].*?<TD>.*?<small>\s*\n\s*(?P<packagename>.*?)\n\s*?</small>.*?<select NAME="status_id">.*?selected>(?P<status>Hidden|Active)''', re.DOTALL | re.IGNORECASE)

PACKAGES_LIMITED_ACCESS = re.compile('''&amp;package_id=(?P<package_id>\d*)">(?P<package>.*?)</a>''', re.IGNORECASE)

PACKAGES_NO_ACCESS = re.compile('''Permission Denied''')

PROJECTS_FROM_LOGIN = re.compile('''<a href="rmproject.php\?group_id=(?P<groupid>\d*)">.*?<a href="/projects/(?P<unixname>.*?)/">(?P<projectname>.*?)</a>''', re.DOTALL | re.IGNORECASE) ### DEPRECATED in 0.9.5

GET_RELEASE_ID = re.compile('''<form enctype=.*? name="release_id" value="(?P<releaseid>\d*)"''', re.DOTALL)

GET_FILE_ID = re.compile('''name="file_id" value="(?P<fileid>\d*).*?name="step3" value="1">.*?<font size="-1">(?P<filename>.*?)</td>.*?value="Delete File"''', re.DOTALL)

GET_RELEASES = re.compile(r'''<font size="-1">(?P<name>.*?)<a.*?release_id=(?P<releaseid>\d*).*?(?P<status>Active|Hidden)''', re.DOTALL)

GET_NOTES_AND_LOG = re.compile(r'''<textarea name="release_notes".*?>(?P<releasenotes>.*?)</textarea>.*?<textarea name="release_changes".*?>(?P<changelog>.*?)</textarea>''', re.DOTALL)


GET_FILE_NAMES_ETC = re.compile('''name="file_id" value="(?P<fileid>\d*)".*?name="step3" value="1".*?<font size="-1">(?P<filename>.*?)<.*?<select NAME="processor_id">(?P<processor>.*?)</select>.*?<select NAME="type_id">(?P<type>.*?)</select>.*?</form>.*?value="Delete File">''', re.DOTALL)

GET_SELECTED_VALUE = re.compile('''selected>(?P<value>.*?)<''')

GET_FILE_WARNINGS = re.compile('''.*?checkbox.*?>(?P<filename>.*?)\s-\s<i><font color="red">Warning</font>:''')

##GET_FILE_PROCESSOR = re.compile('''<select NAME="processor_id">.*?selected>.*?</select>''', re.DOTALL)
##GET_FILE_TYPE = re.compile('''<select NAME="type_id">.*?selected>(?P<type>.*?</select>''', re.DOTALL)
##GET_FILE_ID = re.compile('''name="file_id" value="(?P<fileid>\d*)''', re.DOTALL)


PROJECTS_FROM_MY_PROJECTS = re.compile('''<a href="(?:/my/)?rmproject.php\?group_id=(?P<groupid>\d*)">.*?<a href="/projects/(?P<unixname>.*?)">(?P<projectname>.*?)</a>''', re.DOTALL | re.IGNORECASE)
