def create_document(number):
 file_list = glob.glob(('%s*.jpg' % doc_path))
 random_index = randint(0, (len(file_list) - 1))
 file_uri = file_list[random_index]
 title = ('Document N. %s' % number)
 img_filename = ('%s_img.jpg' % number)
 doc = Document(title=title, owner=get_random_user())
 doc.save()
 with open(file_uri, 'r') as f:
  img_file = File(f)
  doc.doc_file.save(img_filename, img_file, True)
 assign_keywords(doc)
 resource = doc.get_self_resource()
 set_resource(resource)

def create_document ( number ) : file_list = glob . glob ( ( '%s*.jpg' % doc_path ) ) random_index = randint ( 0 , ( len ( file_list ) - 1 ) ) file_uri = file_list [ random_index ] title = ( 'Document N. %s' % number ) img_filename = ( '%s_img.jpg' % number ) doc = Document ( title = title , owner = get_random_user ( ) ) doc . save ( ) with open ( file_uri , 'r' ) as f : img_file = File ( f ) doc . doc_file . save ( img_filename , img_file , True ) assign_keywords ( doc ) resource = doc . get_self_resource ( ) set_resource ( resource )
creates a new document .