build/lib/lottie_animation_manager/__main__.py
def uploadDirectory(directory_name):
	'''
		This is the bread and butter of the application.  Does a few things:
		1. Let's the user know which files it has discovered
		2. Confirm the want to proceed
		3. Optionally compress the images
		4. Upload the images to s3 under specified animation name, inside the request s3 bucket
	'''
	global bucket
	global configured_tiny_png_key
	global compression_enabled

	# Screen Title
	click.echo(click.style(emoji.emojize(' Upload Current Working Directory :up_arrow:  '), bg='green', fg="bright_white"))
	# Screen Instructions
	click.echo(click.style("Make sure you are 'inside' of the animation directory with all of your lottie assets.\n", fg="green"))
	click.echo(click.style(emoji.emojize('Lottie Animation Manager has discovered the following files in the current directory: '),
						   fg='green'),
			   			   nl=True)
	# list out current files which will be sent to the user, ignoring .ds_store files generated by MacOS
	file_count = 0
	for root, dirs, files in os.walk("."):
		for f in files:
			current_file = os.path.relpath(os.path.join(root, f), ".")
			if not ".DS_Store" in current_file:
				if os.sep in current_file:
					click.echo(click.style(" {}".format(current_file), fg="blue"))
					file_count += 1
				else:
					click.echo(click.style(current_file, fg="blue"))
					file_count += 1

	click.echo('\n')
	click.echo(click.style('The above',
							fg='white'),
							nl=False)
	click.echo(click.style(' {} files '.format(file_count),
							bold=True,
							fg='white'),
							nl=False)

	# confirm they want to proceed with the upload process
	if click.confirm(click.style('will be uploaded to AWS S3 Storage.  Please confirm'.format(file_count),
							fg='white'),
							abort=True):
		# Clear screen
		if compression_enabled == True:
			click.clear()
			# Title
			click.echo(click.style(emoji.emojize(' Compressing & Uploading Animation Assets '), bg='green', fg="bright_white"))
			click.echo('\n')
			# compress any images first
			for root, dirs, files in os.walk("."):
				for f in files:
					current_file = os.path.relpath(os.path.join(root, f), ".")
					temp_current_file = current_file.lower()
					if temp_current_file.endswith(".png") or temp_current_file.endswith(".jpg") \
						or temp_current_file.endswith(".jpeg"):
						compress_image(current_file)

		click.echo('\n')
		click.echo(click.style('Uploading animation asset files to AWS S3 Storage Bucket:',
					fg="green"),
					nl=True)
		# the user has confirmed, images are compressed, now send it up to s3
		for root, dirs, files in os.walk("."):
			for f in files:
				current_file = os.path.relpath(os.path.join(root, f), ".")
				if not ".DS_Store" in current_file:
					try:
						k = bucket.new_key("{}/{}".format(directory_name, current_file))
						k.set_contents_from_filename(current_file)
						k.set_acl('public-read')
						click.echo(click.style('{} - Upload successful'.format(current_file),
											   fg="bright_cyan"))
					except:
						click.echo('Error uploading file to s3!')

		# Send them to the view animations listing view, now that we're done here
		if(click.confirm('\nAll done!  Do you want to continue to the animations listings section?')):
			list_hosted_animations()
		else:
			click.echo(click.style(emoji.emojize("Thanks for using Lottie Animation Manager, have a nice day :sun: \n"), fg='bright_green'))
	else:
		# terminate the program
		click.echo(click.style(emoji.emojize("Thanks for using Lottie Animation Manager, have a nice day :sun: \n"), fg='bright_green'))

		This is the bread and butter of the application.  Does a few things:
		1. Let's the user know which files it has discovered
		2. Confirm the want to proceed
		3. Optionally compress the images
		4. Upload the images to s3 under specified animation name, inside the request s3 bucket
	
This is the bread and butter of the application.  Does a few things:
1. Let's the user know which files it has discovered
2. Confirm the want to proceed
3. Optionally compress the images
4. Upload the images to s3 under specified animation name, inside the request s3 bucket
This is the bread and butter of the application . Does a few things : 1 . Let ' s the user know which files it has discovered 2 . Confirm the want to proceed 3 . Optionally compress the images 4 . Upload the images to s3 under specified animation name inside the request s3 bucket
def uploadDirectory(directory_name):
	global bucket
	global configured_tiny_png_key
	global compression_enabled
	click.echo(click.style(emoji.emojize(' Upload Current Working Directory :up_arrow:  '), bg='green', fg="bright_white"))
	click.echo(click.style("Make sure you are 'inside' of the animation directory with all of your lottie assets.\n", fg="green"))
	click.echo(click.style(emoji.emojize('Lottie Animation Manager has discovered the following files in the current directory: '),
						   fg='green'),
			   			   nl=True)
	file_count = 0
	for root, dirs, files in os.walk("."):
		for f in files:
			current_file = os.path.relpath(os.path.join(root, f), ".")
			if not ".DS_Store" in current_file:
				if os.sep in current_file:
					click.echo(click.style(" {}".format(current_file), fg="blue"))
					file_count += 1
				else:
					click.echo(click.style(current_file, fg="blue"))
					file_count += 1
	click.echo('\n')
	click.echo(click.style('The above',
							fg='white'),
							nl=False)
	click.echo(click.style(' {} files '.format(file_count),
							bold=True,
							fg='white'),
							nl=False)
	if click.confirm(click.style('will be uploaded to AWS S3 Storage.  Please confirm'.format(file_count),
							fg='white'),
							abort=True):
		if compression_enabled == True:
			click.clear()
			click.echo(click.style(emoji.emojize(' Compressing & Uploading Animation Assets '), bg='green', fg="bright_white"))
			click.echo('\n')
			for root, dirs, files in os.walk("."):
				for f in files:
					current_file = os.path.relpath(os.path.join(root, f), ".")
					temp_current_file = current_file.lower()
					if temp_current_file.endswith(".png") or temp_current_file.endswith(".jpg") \
						or temp_current_file.endswith(".jpeg"):
						compress_image(current_file)
		click.echo('\n')
		click.echo(click.style('Uploading animation asset files to AWS S3 Storage Bucket:',
					fg="green"),
					nl=True)
		for root, dirs, files in os.walk("."):
			for f in files:
				current_file = os.path.relpath(os.path.join(root, f), ".")
				if not ".DS_Store" in current_file:
					try:
						k = bucket.new_key("{}/{}".format(directory_name, current_file))
						k.set_contents_from_filename(current_file)
						k.set_acl('public-read')
						click.echo(click.style('{} - Upload successful'.format(current_file),
											   fg="bright_cyan"))
					except:
						click.echo('Error uploading file to s3!')
		if(click.confirm('\nAll done!  Do you want to continue to the animations listings section?')):
			list_hosted_animations()
		else:
			click.echo(click.style(emoji.emojize("Thanks for using Lottie Animation Manager, have a nice day :sun: \n"), fg='bright_green'))
	else:
		click.echo(click.style(emoji.emojize("Thanks for using Lottie Animation Manager, have a nice day :sun: \n"), fg='bright_green'))
def uploadDirectory ( directory_name ) : global bucket global configured_tiny_png_key global compression_enabled click . echo ( click . style ( emoji . emojize ( ' Upload Current Working Directory :up_arrow:  ' ) , bg = 'green' , fg = "bright_white" ) ) click . echo ( click . style ( "Make sure you are 'inside' of the animation directory with all of your lottie assets.\n" , fg = "green" ) ) click . echo ( click . style ( emoji . emojize ( 'Lottie Animation Manager has discovered the following files in the current directory: ' ) , fg = 'green' ) , nl = True ) file_count = 0 for root , dirs , files in os . walk ( "." ) : for f in files : current_file = os . path . relpath ( os . path . join ( root , f ) , "." ) if not ".DS_Store" in current_file : if os . sep in current_file : click . echo ( click . style ( " {}" . format ( current_file ) , fg = "blue" ) ) file_count += 1 else : click . echo ( click . style ( current_file , fg = "blue" ) ) file_count += 1 click . echo ( '\n' ) click . echo ( click . style ( 'The above' , fg = 'white' ) , nl = False ) click . echo ( click . style ( ' {} files ' . format ( file_count ) , bold = True , fg = 'white' ) , nl = False ) if click . confirm ( click . style ( 'will be uploaded to AWS S3 Storage.  Please confirm' . format ( file_count ) , fg = 'white' ) , abort = True ) : if compression_enabled == True : click . clear ( ) click . echo ( click . style ( emoji . emojize ( ' Compressing & Uploading Animation Assets ' ) , bg = 'green' , fg = "bright_white" ) ) click . echo ( '\n' ) for root , dirs , files in os . walk ( "." ) : for f in files : current_file = os . path . relpath ( os . path . join ( root , f ) , "." ) temp_current_file = current_file . lower ( ) if temp_current_file . endswith ( ".png" ) or temp_current_file . endswith ( ".jpg" ) or temp_current_file . endswith ( ".jpeg" ) : compress_image ( current_file ) click . echo ( '\n' ) click . echo ( click . style ( 'Uploading animation asset files to AWS S3 Storage Bucket:' , fg = "green" ) , nl = True ) for root , dirs , files in os . walk ( "." ) : for f in files : current_file = os . path . relpath ( os . path . join ( root , f ) , "." ) if not ".DS_Store" in current_file : try : k = bucket . new_key ( "{}/{}" . format ( directory_name , current_file ) ) k . set_contents_from_filename ( current_file ) k . set_acl ( 'public-read' ) click . echo ( click . style ( '{} - Upload successful' . format ( current_file ) , fg = "bright_cyan" ) ) except : click . echo ( 'Error uploading file to s3!' ) if ( click . confirm ( '\nAll done!  Do you want to continue to the animations listings section?' ) ) : list_hosted_animations ( ) else : click . echo ( click . style ( emoji . emojize ( "Thanks for using Lottie Animation Manager, have a nice day :sun: \n" ) , fg = 'bright_green' ) ) else : click . echo ( click . style ( emoji . emojize ( "Thanks for using Lottie Animation Manager, have a nice day :sun: \n" ) , fg = 'bright_green' ) )
This is the bread and butter of the application.
This is the bread and butter of the application .
'''
		This is the bread and butter of the application.  Does a few things:
		1. Let's the user know which files it has discovered
		2. Confirm the want to proceed
		3. Optionally compress the images
		4. Upload the images to s3 under specified animation name, inside the request s3 bucket
	''' # Screen Title # Screen Instructions # list out current files which will be sent to the user, ignoring .ds_store files generated by MacOS # confirm they want to proceed with the upload process # Clear screen # Title # compress any images first # the user has confirmed, images are compressed, now send it up to s3 # Send them to the view animations listing view, now that we're done here # terminate the program
directory_name