Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.filter.application_octet_stream Namespace Reference

Functions

def execute

Variables

int maxread = 10000
int minwordlen = 4
tuple blacklist
tuple norm = string.maketrans('', '')
tuple non_alnum = string.translate(norm, norm, string.letters+string.digits)
tuple trans_nontext = string.maketrans(non_alnum, ' '*len(non_alnum))

Function Documentation

def MoinMoin.filter.application_octet_stream.execute (   indexobj,
  filename 
)

Definition at line 44 of file application_octet_stream.py.

00044 
00045 def execute(indexobj, filename):
00046     fileext = os.path.splitext(filename)[1]
00047     if fileext.lower() in blacklist:
00048         return u''
00049     f = file(filename, "rb")
00050     data = f.read(maxread)
00051     f.close()
00052     data = data.translate(trans_nontext) # replace non-ascii by blanks
00053     data = data.split() # removes lots of blanks
00054     data = [s for s in data if len(s) >= minwordlen] # throw away too short stuff
00055     data = ' '.join(data)
00056     return data.decode('ascii')
00057 

Variable Documentation

Initial value:
00001 ('.iso', '.nrg', # CD/DVD images
00002              '.zip', '.rar', '.lzh', '.lha',
00003              '.tar', '.gz', '.tgz', '.bz2', '.tb2', '.z',
00004              '.exe', '.com', '.dll', '.cab', '.msi', '.bin', # windows
00005              '.rpm', '.deb', # linux
00006              '.hqx', '.dmg', '.sit', # mac
00007              '.jar', '.class', # java
00008             )

Definition at line 24 of file application_octet_stream.py.

Definition at line 21 of file application_octet_stream.py.

Definition at line 22 of file application_octet_stream.py.

tuple MoinMoin.filter.application_octet_stream.non_alnum = string.translate(norm, norm, string.letters+string.digits)

Definition at line 39 of file application_octet_stream.py.

tuple MoinMoin.filter.application_octet_stream.norm = string.maketrans('', '')

Definition at line 36 of file application_octet_stream.py.

Definition at line 42 of file application_octet_stream.py.