; XBc@sdkZdkZdkZdkZdkZdkTeiZ dZ ddfddfddfddfd d fd d fd d fd d fd dfddfddfddfddfddfddfddfddfddfddfddfddfddfddfd d!fd"d!fd#d!fd$d$fd%d%fd&d&fd'd(fd)d)fd*d*fd+d+fd,d-fd.d-fd/d0fd1d2fd3d4fd5d4fd6d7fd8d9fd:d9fd;d9fd<d=fd>d=fd=d=fd?d=fd@d=fdAd=fdBd=fdCd=fdDd=fdEd=fdFdFfdGdGfdHdHfdIdHfdJdJfdKdJfdLdLfdMdNfdOdPfdQdRfdSdTfdUdUfdVdVfdWdWfdXdXfdYdXfdZdXfd[d\fd]d\fd^d\fd_d`fdadafdbdcfdddcfdedefdfdffdgdgfdhdifdjdkfdldlfdmdnfdodpfdqdrfdsdrfdtdufdvdwfdxdwfdydwfdzd{fd{d{fd|d}fd~d}fddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfd2dfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfd d fd d fd d fd d fddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfd d fd!d!fd"d#fd$d#fd%d#fd&d'fd(d)fd*d+fd,d-fd.d-fd/d-fd0d-fd1d2fd3d2fd4d5fd6d7fd8d7fd#d#fd9d:fd;d;fd<d<fd=d'fd+d+fd+d+fd>d?fd@d<fdAd<fdBd2fdCdDfdEdDfdFd2fdGdHfdIdHfdJd+fdKdKfdLdMfdMdMfdNdMfdOdMfdPdQfdRdSfdTdSfdSdSfdUdUfdVdWfdWdWfdXdXfdYdYfdZd[fd\d[fd]d]fd^d^fd_d`fdad`fdbdcfddddfdedffdedffdgdhfdidhfdjdjfdkdlfdldlfdmdnfdodofdpdpfdqdrfdqdrfdsdsfdtdufdvdwfdxdyfdzd{fd|d{fd}d}fd~dfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfddfgZ dddfdddfdddfddcdfdddfdddfdddfdd dfd d dfd ddfd ddfd ddfd d dfdd2dfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfd ddfd!ddfd"d#dfd$d%dfd&d'dfd(d'dfd)d*dfd+d,dfd-d,dfd.ddfd/d0dfd1d0dfd2d3dfd4d5dfd6d7dfd8ddfd9ddfd:d;dfd<d=dfd>d=dfd?ddfd@ddfdAddfdBddfdCddfdDdHdfdEdHdfdFdHdfdGdHdfdHdHdfdIdHdfdJdHdfdKddfdLddfdMddfdNddfdOddfdPddfdQddfdRddfdSdTdfdUdTdfdVdWdfdXdYdfdZd[dfd\d]dfd^d_dfd`dadfdbdadfdcdddfdedddfdfddfdgddfdhdidfdjdkdfdldmdfdndmdfdod dfdpd dfdqd dfdrddfdsddfdtddfduddfdvddfdwddfdxddfdyddfdzddfd{ddfd|ddfd}ddfd~ddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdd dfdd dfdddfdddfdddfdddfdddfdddfdddfddcdfddcdfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdd*dfdddfdddfdddfdddfdddfdddfgZ ddffdd?fdd+fddrfdd$fdd}fdd-fddfddfddfddfddfddHfddfddfddfddfddfddfddufddfddfgZ dmddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfd>ddfdddfd*ddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfdddfddd fddd fd dd fd ddfdddfdddfdddfg#Zeidjo dZngahagagagahhgZhaddddddddddd2dd#dd3dXdddfd d!d"d#ddddd$d%dd&d'dd2d(d'd?d+d[d)dcddd*d+d,d-dld.d/dd0d1dd2d3d4d5d6d7d8dd9d:dddddddddd;dd<d=gLZdad>Zd?efd@YZdAZdBZdedCZ edDZ!edEZ"dFfdGYZ#dHfdIYZ$dJZ%dKZ&dLZ'dMZ(dNZ)dOZ*dPZ+dQZ,dRZ-dedSZ.dTZ/e0dUjoe1gZ2eZ3dZ dZ4dZ5xJei6dD];Z7e4o e2i8hdVe7<dZ4q8e5o e2i8hdWe7<dZ5q8e9e7dXjoe7dX dYjo;e9e7dXjoe2i8hdVe7dX<qsdZ4q8e9e7dXjoe7dX dZjo;e9e7dXjoe2i8hdWe7dX<qsdZ5q8e3oe:d[GHei;dne7Z3q8We4oe:d\GHei;dne5oe:d]GHei;dne3 o'e:d^ei6dGHei;dnex_e2D]WZ<e<i=dVoe e<dVqye!e<dWWqej oZ>e>GHqXqWySe.ei6dZ?e?djoe.ei6ddGd_GHne.ei6dGHWqej o#Z>ei@iAd`eBe>qXndS(aN(s*isaapsabcsablsabelswrmsacedbsadasadbsadssafdstdfsahdlsamlsrunsamplsasasmslstsmacsssasnsasn1sasasaspvbssassatlassatlsavesawksimpsbsmchsrefsbcsbdfsbibsblsblanksbtmscscdlscfiscfscfmschsschaskellsenisclsdclscleansiclsprgsclipperscblscobolscobscpysc++scppsccscxxshshhshppshxxsinlstccscsscscscshstcshscspsfdrscsssconsctermspldscuplssiscuplsimscynscynppsdsdefsdescsdiffspatchsrejsbatsdosbatchscmdssyssinisdosinisdotsdracsdraculasdrcsdslsdtdsdylansintrs dylanintrslidsdylanlidsecdsamselfserlserlangsECsesqlcsecsexpsexpects4ghsfgls4glsm4glsfexsfocexecsfssforthsftsFsfortransfsf77sf90sf95sforsfppsftnsgdmosmosgedsgedcomsgifsgpisgnuplotsgpsgspshsshaskellshbserrsumsherculessevsrsssumsvcsh32shexshogsrulesshtmshtmlsshtmlshtml.m4shtmlm4sicnsiconsidlsZsignoresbaksbz2sgzsinsnewsoldsorigsrmpnewsrpmsaves indent.prosindentsINFsinformsinfsisssistsmstsjplsjamsjprsjavsjavasjjsjavaccsjjts javascriptsjssclpsjesssjgrsjgraphsjpgsjpegspngs propertiess jpropertiessjspskixsksskscriptskskwtsACEslacesaceslatteslteslslexslhsslhaskellsllslexppslispselsjlslspslitesltslgtslogtalkslotslotosslousloutssigslprologslsssluasmcsm4semlsmailsdspsmakesmaksmksmansmplsmaplesmvsmwssmasonsmhtmlsmelsmfsmgpsmibsmmssmmixsmocsDEFsmodula2sMODsm2smdsmisi3smodula3sigsm3smgsiscsmonkssscstscsmoosmpsmsqlsmushsmysqls.NSAsnaturals.NSCs.NSGs.NSLs.NSMs.NSNs.NSPs.NSSsncfsnqcsOPLsoplsOPlsOplsdprspascalsgspcctssincsphpsmlsocamlsmlismllsmlysmmsnroffsnrsnsisnsissosobjectsobjsorsopenroadsoraspappspassplsperlspxmlspxslsroffsshos dllobjectssobstrsxinsomnimarksxomsphp3sphtmlslpcspikespmodsulpcsrcpspilrcsp36splmspacsplpsplssplsqlspospodsepss postscriptspsspovsppdsihsppwizsitspdbsprologspsfspyspythonsmatsradiancesradsrcsrexsrexxsxsrpcgensrplsrtfsrbwsrubyssasssassathersscmsschemesscisscilabspdlssdlsprssedssgmssgmlsbashsshsebuildsenvskshssimssimulass85ssindassinsilsskillsslsslangsscoresslrnscstplssmartyssmithssmtssmlssnossnobol4sspecsspsspicesspdsspupsspdatasspeedupspkbssqlspksstybstycstypssqljssqissqrss19ssrecss28ss37sclssstsstpstaksitclstclsitkstarstar.bz2starbz2star.gzstargzstgzstkstisterminfosdtxstexslatexsltxsstystexistexinfostxistfst.htmlstildestlissltstsaltstssclstssgmstssopsucsuisuilsuitsctlsvbsdsmssbasvbssvsverilogshdlsvhdlsvbesvhdsvstsvimshwsviratasmodulespkgswrlsvrmlswmswebmacroswbtswinbatchswmlsdocswordswscswshswsfsads xdefaultssmscsxmathsmsfsxpm2sxssxsdsxslsxsltsysyaccsyysyaccppszipsz8as[cC]hange[lL]ogs changelogis /var/named/sbindzonescrontabs .*\drac\.s.*fvwmrcsfvwms.*fvwm95s .*fvwm2rcs\.gtkrcsgtkrcsPrl.*\.sJAM.*\.s [mM]akefilesmuttrcstmac\.s .*printcapsprintcaps .*termcapstermcaps.*vimrcs Xresourcess.*/app-defaults/s.*/Xresources/s XF86Configsxf86confs .*xmodmapsxmodmapszshszlogs xdm-config$s \.Xresources$s \.Xpdefaults$s \.Xdefaults$s XF86Config$scvs\d+$scvss wvdial\.conf$swvdials\wgetrc$swgets \.wgetrc$s vgrindefs$s vgrindefss \.viminfosviminfos \_viminfos.*\.vhdl_[0-9]*$s\tidyrc$stidys \.tidyrc$s texmf\.cnf$stexmfstags$stagss squid\.conf$ssquids vision\.conf$s snort\.conf$s\.lrnrcsslrnrcs screenrc$sscreens \.screenrc$s \.zcompdumps \.zfbfmarks$s \.zprofile$s\.zlogs\.zshs csh\.logout$s csh\.login$s csh\.cshrc$s\.aliass\.tcshrcs\.cshrcs\.logins \.profiles /etc/profiles\.kshrcs\.bashrcsbashrcs bash\.bashrcs\.bash_profiles \.bash_logouts sgml\.catalogscatalogscatalog$s sendmail\.cfssendmails smb\.confssambas robots.txtsrobotss \.reminderssreminds \.inputrc$sreadlines\.ratpoisonrc$s ratpoisons \ratpoisonrc$s \.procmail$sprocmails \.procmailrc$s .*printcap$s .*termcap$s \.povrayrc$spovinismain.cf$spfmains \.pinerc$spines\pinerc$s\.muttrcs \.mutt/muttrcsMuttrc$s [mM]akefile$s GNUmakefile$ssnd.\d+$s \.letter$s\.letter\.\d+$s \.followup$s \.article$s\.article\.\d+$s \pico\.\d+$s \mutt-.*-\d+$s \mutt\w{6}$s \ae\d+\.txt$s/tmp/SLRN[0-9A-Z.]+$s\.emacs$s \.sawfishrc$s lilo.confslilos lftp.conf$slftps \.lftprc$s .*lftp/rc$s.*properties_..$s.*properties_.._..$s.*properties_.._.._.*$sinittab$sinittabs\.gtkrc$sgtkrc$s gkrellmrc_.$s gkrellmrcs gkrellmrc$s \.gdbinit$sgdbsfstab$sfstabs auto.master$sconfsexports$sexportss filter-rules$selmfilts.*lvs$s.*lpe$sdebian/control$s debcontrols .*\.\.ch$schs named\.conf$snameds named\.root$s build\.xml$sants.*vimrc$s.*exrc$s configure$s configure.ac$sconfigs .*COPYING$stexts .*README$s .*read.me$s proftpd\.confs apachestyles httpd\.confsapaches srm\.confs access\.confs apache\.confs \.htaccess$s.*enlightenment/.*\.cfg$s.*Eterm/.*\.cfg$seterms lynx\.cfg$slynxs.*baseq[2-3]/.*\.cfg$squakes.*id1/.*\.cfg$s.*quake[1-3]/.*\.cfg$scrontab$s .*\bpythons.*\bperls.*\bphps.*\brubys.*\bbc\bs .*\bsed\bs .*\bocamls.*awk\bs.*wml\bs .*\bksh\bs.*\bsh\bs.*\bbashs.*csh\bs .*\bzsh\bs .*\btclsh\bs .*\bwish\bs .*\bexpectk\bs .*\bitclsh\bs .*\bitwish\bs .*\bexpect\bs .*\bgnuplot\bs.*make\bs # Use Python to avoid the .am suffix is recognized if string.lower(fname_base) == "makefile.am": type = "automake" sbas,frmsO if string.lower(fname[-3:]) == "frm": type = "form" else: type = "basic" f = open(fname) l = '' try: for i in xrange(1,5): l = l + f.readline() except: pass f.close() if re.search("VB_Name|Begin VB\\.(Form|MDIForm|UserControl)", l, re.I): type = "vb" s type = "ch" f = open(fname) try: for i in xrange(1,10): if f.readline()[0] == '@': type = "change" break except: pass f.close() se,Es type = "eiffel" f = open(fname) try: for i in xrange(1,100): if cre_match("\\s*(<'|'>)\\s*$", f.readline()): type = "specman" break except: pass f.close() sents+ type = "dtd" f = open(fname) try: for i in xrange(1,6): l = f.readline() if cre_match("\\s*[#{]", l): type = "cl" break if not cre_match("\\s*$", l): break except: pass f.close() sruls type = "diva" f = open(fname) try: for i in xrange(1,6): if string.find("InstallShield", f.readline()): type = "ishd" break except: pass f.close() scoms1 type = "dcl" f = open(fname) try: l1 = f.readline() + f.readline() l2 = f.readline() + f.readline() if (cre_search("\\$ORIGIN|\\$TTL|IN\\s*SOA", l1) or cre_search("BIND.*named", l1 + l2)): type = "dns" except: pass f.close() st # Use Python to avoid the .in suffix is recognized if fname_base == "configure.in": type = "config" sms type = "matlab" f = open(fname) try: for i in xrange(1,10): l = f.readline() if cre_match("\\s*#(include|import)", l): type = "objc" break if cre_match("\\s*%", l): break if cre_match("\\s*\\(\\*", l): type = "mma" break except: pass f.close() smods type = "modsim3" f = open(fname) try: if cre_search("\\bmodule\\b", f.readline()): type = "lprolog" except: pass f.close() s1,2,3,4,5,6,7,8,9,t,mss f = open(fname) found = 0 try: for i in xrange(1,5): l = f.readline() if not l: break if l[0] == '.': type = "nroff" found = 1 break except: pass f.close() if not found: if fname[-1] == 't': type = "tads" elif fname[-1] == 's': type = "xmath" s# type = "perl" f = open(fname) try: while 1: l = f.readline() if l: break except: pass f.close() if (cre_search("\\bprolog\\b|:-", l) or cre_match("\\s*(%+(\\s|$)|/\\*)", l)): type = "prolog" spms type = "perl" f = open(fname) try: l = f.readline() except: pass f.close() if cre_search("XPM2", l): type = "xpm2" elif cre_search("XPM", l): type = "xpm" s type = "php" f = open(fname) l = '' try: for i in xrange(1,3): l = l + f.readline() except: pass f.close() if cre_search("perlscript", l): type = "aspperl" elif cre_search("<%", l): type = "aspvbs" elif cre_search("", f.readline()): type = "xml" except: pass f.close() ssmis type = "mib" f = open(fname) try: if cre_search("\\bsmil\\b", f.readline()): type = "smil" except: pass f.close() swebs type = "winbatch" f = open(fname) try: for i in xrange(0,5): if f.readline()[0] == '%': type = "web" break except: pass f.close() sxpms type = "xpm" f = open(fname) try: if cre_search("XPM2", f.readline()): type = "xpm2" except: pass f.close() sxmls type = "xml" ssx while 1: if fname == "INDEX" or fname == "INFO": f = open(fname) try: if cre_match("\\s*(distribution|installed_software|root|bundle|product)\\s*$", f.readline()): type = "psf" f.close() break except: pass f.close() if string.find("jarg", fname): f = open(fname) try: for i in xrange(0,5): if re.search("THIS IS THE JARGON FILE", f.readline(), re.I): type = "jargon" break except: pass f.close() break sL if ignore and fname[-1] == '~': type = ft_detect(fname[:-1], 1) s f = open(fname) line1 = f.readline() lines = ['', line1, '', '', '', ''] for i in xrange(2, 6): try: lines[i] = f.readline() except: break if line1 and line1[0] == ':' and line1[1] == '\\n': type = "sh" elif cre_match("#(compdef|autoload)\\b", line1): type = "zsh" elif cre_match("From [a-zA-Z][a-zA-Z_0-9\\.=-]*(@[^ ]*)? .*[12][09]\\d\\d$", line1): type = "mail" elif cre_match("<[%&].*>", line1): type = "mason" elif cre_match('" *[vV]im$', line1): type = "vim" elif cre_match("\\*\\* LambdaMOO Database, Format Version", line1): type = "moo" elif (cre_match("diff\\b|Only in |\\d+(,\\d+)?[cda]\\d+\\b|# It was generated by makepatch |Index:\\s+\\S+$|==== //\\S+#\\d+", line1) or (cre_match("--- ", line1) and cre_match("+++ ", lines[2])) or (cre_match("\\*\\*\\* ", line1) and cre_match("--- ", lines[2]))): type = "diff" elif cre_match("%!\\s*PS", line1): type = "postscript" elif (cre_match("\\s*dnl\\b", line1) or cre_match("\\s*dnl\\b", lines[2]) or cre_match("\\s*dnl\\b", lines[3]) or cre_match("\\s*dnl\\b", lines[4]) or cre_match("\\s*dnl\\b", lines[5])): type = "m4" elif re.match(" *proc[nd] *$", line1, re.I): type = "sicad" elif cre_match("\\*\\*\\* Purify", line1): type = "purifylog" elif cre_search("<\\?\\s*xml.*\\?>", line1): type = "xml" elif cre_match("[0-9a-fA-F]{7}: [0-9a-fA-F]{2} [0-9a-fA-F]{2} [0-9a-fA-F]{2} [0-9a-fA-F]{2} ", line1): type = "xxd" elif cre_match("RCS file:", line1) or cre_match("RCS file:", lines[2]): type = "rcslog" elif cre_match("CVS:", lines[2]): type = "cvs" elif cre_match("SEND-PR:", line1): type = "sendpr" elif cre_match("SNNS network definition file", line1): type = "snnsnet" elif cre_match("SNNS pattern definition file", line1): type = "snnspat" elif cre_match("SNNS result file", line1): type = "snnsres" elif (cre_match("%.*?[Vv]irata", line1) or cre_match("%.*?[Vv]irata", lines[2]) or cre_match("%.*?[Vv]irata", lines[3]) or cre_match("%.*?[Vv]irata", lines[4]) or cre_match("%.*?[Vv]irata", lines[5])): type = "virata" elif cre_match("[0-9]* *execve\\(", line1): type = "strace" elif (cre_search("K & K Associates", lines[4]) or cre_search("TAK 2000", lines[2])): type = "takout" elif cre_search("S Y S T E M S I M P R O V E D ", lines[3]): type = "sindaout" # takcmp and sindacmp skipped elif (cre_search("\\$ORIGIN|\\$TTL|IN\\s*SOA", line1 + lines[2]) or cre_search("BIND.*named", line1 + lines[2] + lines[3] + lines[4])): type = "dns" elif ((cre_search("\\|\\*{1,80}", line1) and cre_search("VRC ", lines[2])) or (cre_search("\\|\\*{1,80}", lines[2]) and cre_search("VRC ", lines[3]))): type = "baan" elif cre_match("==\\d+== valgrind", line1): type = "valgrind" else: line = None for i in xrange(1,6): if not cre_match("\\? ", lines[i]): line = lines[i] break if not line: while 1: try: l = f.readline() if not cre_match("\\? ", l): line = l break except: break if line and cre_match("Index:\\s+\\S+$", line): type = "diff" f.close() s mas,masters type = "master" s type = "m4" smes type = "nroff" stxts type = "text" sinpsv f = open(fname) try: l = f.readline() if l[0] == '*': type = "abaqus" else: for i in xrange(1, 500): if len(l) >= 19 and string.lower(l[:19]) == "header surface data": type = "trasys" break l = f.readline() except: pass f.close() sasps type = "aspvbs" f = open(fname) try: l = f.readline() l = l + f.readline() l = l + f.readline() except: pass if string.find("perlscript", string.lower(l)) >= 0: type = "aspperl" f.close() scfgs type = "cfg" sposixs9 suffix L lisp suffix C cpp suffix H cpp sabaqussaspperlsautomakesbaansbasicschangescwebsdivasdnsseiffelsformsishdsjargonsmastersmatlabsmmasmodsim3sobjcsprogresss purifylogsrcslogsrebolsregistryssendprssgmldeclssicadssindaoutssnnsnetssnnspatssnnsressspecmansstracestadsstakoutstrasyssvalgrindsxxds libobjectsltobjectcCstodSndagahagagagahattt t t t t ttidjottdnx-thD]}ttii|dqWxtD]}dt|scCstii|otii|oxtitii|dD]e}yt||WqEt j o?}t ot |GHqdkl}||t |qEXqEWnF|o>td|}t o |GHqdkl}|||ndS(sCheck directory "dir" for *.afd files and load them. When "errmsg" is non-zero give an error message when the directory doesn't exist.s*.afd(s msg_errorsDirectory does not exist: "%s"N(sosspathsexistssdirsisdirsglobsjoinsfs ft_read_filesrecdicts DetectErrorses_run_as_programsstrsMessages msg_errorserrmsgs_(sdirserrmsgsrecdictsesfs msg_error((s-/mnt/gmirror/ports/devel/aap/work/Filetype.pys ft_check_dirCs"&    cCsyt|}Wn2tj o&}ttd|t|nXy|i}Wn2tj o&}ttd|t|nX|i t |d|dS(s0Read file "fname" for file type detection rules.sCannot open "%s": sCannot read "%s": iN( sopensfnamesfdsIOErrorses DetectErrors_sstrsreadssscloses ft_add_rulessrecdict(sfnamesrecdictsesssfd((s-/mnt/gmirror/ports/devel/aap/work/Filetype.pys ft_read_fileZs"" cCsLtti|d}d}t|}x||jo ||}ti|t d}t|djp|dddjo|d}q.n|d}t|djo d}n |d}t|}d} | |jo|| djp|| djo|| }| d} | } x-| |jo|| |jo| d} q"W| |jo!ttd |||fn| d}nN| } x>| |jo|| d jo|| d jo| d} qW| }|| | !}n d}|}ti||}t|djo|d}nd}t|djo|d}nd}t|d jo|d}nd}|d ddgjo| p|djo| o!ttd|||fn|djodt|