Module uniquely
[hide private]
[frames] | no frames]

Module uniquely

source code

Process a Release file, creating, finding and updating any torrent files.

Functions [hide private]
dictionary, list of string
read_release(filename)
Read the headers and Packages file names from a Release file.
source code
dictionary, dictionary
get_old(old_file)
Read the headers and piece ordering data from an old file.
source code
boolean
update_headers(headers, release_headers, component, arch)
Update the headers with new fields from the Release file.
source code
dictionary
get_new(filename, old_files, old_all_files, all_pieces, all_new_pieces)
Read the new piece data from a Packages file.
source code
 
add_new(pieces, new_pieces, headers)
Read the new piece data from a Packages file.
source code
 
write_file(filename, pieces, headers)
Print the new data to the file.
source code
 
run(releasefile)
Process a single Release file.
source code
Variables [hide private]
  DEFAULT_PIECESIZE = 524288
  EXTENSION = '.gz'
  DEFAULT_HASH_FIELDS = ['Codename', 'Suite', 'Component', 'Arch...
  DEFAULT_TRACKER = 'http://dttracker.debian.net:6969/announce'
  HEADER_ORDER = ['Torrent', 'Infohash', 'InfohashArchs', 'Origi...

Imports: sha, sys, gzip, bz2.BZ2File, math.ceil, os.remove, os.path.exists, time.strftime, time.gmtime


Function Details [hide private]

read_release(filename)

source code 
Read the headers and Packages file names from a Release file.
Parameters:
  • filename (string) - the Release file to read
Returns: dictionary, list of string
the headers and full file names of Packages files

get_old(old_file)

source code 
Read the headers and piece ordering data from an old file.
Parameters:
  • old_file (string) - the old piece ordering file to open
Returns: dictionary, dictionary
the old piece ordering (keys are the file names, values are the starting piece number) and headers

update_headers(headers, release_headers, component, arch)

source code 
Update the headers with new fields from the Release file.
Parameters:
  • headers (dictionary) - the headers from the piece ordering file
  • release_headers (dictionary) - the headers from the Release file
  • component (string) - the component name (e.g. main, contrib, non-free)
  • arch (string) - the architecture name (e.g. i386, amd64, all)
Returns: boolean
whether a new torrent has been created

get_new(filename, old_files, old_all_files, all_pieces, all_new_pieces)

source code 

Read the new piece data from a Packages file.

Reads the Packages file, finding old files in it and copying their data to the new ordering, and adding any new files found to the end of the ordering. The old_files input is modified by removing the found files from it, and the 'NextPiece' header in the input headers is changed.

Any architecture:all files found are processed and added to the 'all' piece ordering. This is done by modifying the input old_all_files, all_pieces, and all_new_pieces variables.
Parameters:
  • filename (string) - the Packages file to open and parse
  • old_files (dictionary) - the original piece ordering, keys are the file names, values are the starting piece number
  • old_all_files (dictionary) - the original piece ordering for architecture:all files, keys are the file names, values are the starting piece number
  • all_pieces (dictionary) - the new piece ordering for architecture:all files, keys are the starting piece numbers, values are the file names
  • all_new_pieces (list of (string, long)) - the file name and file size of the new architecture:all files that have been found
Returns: dictionary
the new piece ordering, keys are the starting piece numbers, values are the file names

add_new(pieces, new_pieces, headers)

source code 

Read the new piece data from a Packages file.

Adds new files to the end of the piece ordering. The 'pieces' input is modified by having the new pieces added to it. The 'new_pieces' input list is sorted. The 'NextPiece' header in the input 'headers' is updated.
Parameters:
  • pieces (dictionary) - the current piece ordering, keys are the starting piece numbers, values are the file names
  • new_pieces (list of (string, long)) - the file name and file size of the new files that have been found and are to be added to the pirce ordering
  • headers (dictionary) - the headers from the piece ordering file

write_file(filename, pieces, headers)

source code 
Print the new data to the file.
Parameters:
  • filename (string) - the file to write to
  • pieces (dictionary) - the current piece ordering, keys are the starting piece numbers, values are the file names
  • headers (dictionary) - the headers from the piece ordering file

run(releasefile)

source code 
Process a single Release file.
Parameters:
  • releasefile (string) - the Release file to process

Variables Details [hide private]

DEFAULT_HASH_FIELDS

Value:
['Codename',
 'Suite',
 'Component',
 'Architecture',
 'PieceSize',
 'OriginalDate']

HEADER_ORDER

Value:
['Torrent',
 'Infohash',
 'InfohashArchs',
 'OriginalDate',
 'Date',
 'PieceSize',
 'NextPiece',
 'OriginalPieces',
...