#NEWLINE# def get_file_path( instance , filename , default_dir = 'attachments' ) : #NEWLINE# #INDENT# 'Generates pseudo-random file path.\n\n    Function generate hard to guess file path based on arguments and\n    uuid4. In most cases is used in FileField as upload_to argument but\n    you can use standalone as well.\n\n    Args:\n        instance: Model instance. Unused.\n        filename: A original file name with extension.\n        default_dir: Something like namespace for files. The\n\n    Returns:\n        A generated filename with schema:\n            {attachment}/{1st_uuid_char}/{2nd_uuid_char}/{uuid}.{ext}\n    ' #NEWLINE# ext = os . path . splitext ( name ) [ 1 ] #NEWLINE# name = '' . join ( [ str ( uuid4 ( ) ) , ext ] ) #NEWLINE# return os . path . join ( default_dir , name [ : 1 ] , name [ 1 : 2 ] , name )