<commit_before>#!C:\Python27\python.exe

import sys, os

from PyQt4 import QtCore, QtGui

from docx import Document
from docx.shared import Cm, Inches, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
from PIL import Image
from StringIO import StringIO

import dokumentasi_ui

Ui_Main = dokumentasi_ui.Ui_MainWindow

def main():
	app = QtGui.QApplication(sys.argv)
	window = Dokumentasi()
	window.show()
	sys.exit(app.exec_())

class Dokumentasi(QtGui.QMainWindow, Ui_Main):
	def __init__(self):
		super(Dokumentasi, self).__init__()
		self.setupUi(self)

		self.setWindowTitle('AutoDoc v1.1 - Karogis')
		self.logger('====================================')
		self.logger('||          *****            www.karogis.com            *****         ||')
		self.logger('====================================\n\n\n')

		self.logVisible = False
		self.toggleLog()

		self.statusbar.showMessage('Siap')
		self.btnInput.clicked.connect(self.browseInput)
		self.btnOutput.clicked.connect(self.browseOutput)
		self.btnExit.clicked.connect(self.close)
		self.btnStart.clicked.connect(self.start)
		self.btnLog.clicked.connect(self.toggleLog)


	def browseInput(self):
		directory = QtGui.QFileDialog.getExistingDirectory(self)
		if directory:
			self.inputFolder.setText(directory)
			self.logger('Folder Sumber: ' + directory)

			self.dirs = 0
			self.images = 0
			self.evaluateDirectory(directory)

			self.logger('Jumlah Folder: ' + str(self.dirs))
			self.logger('Jumlah Foto: ' + str(self.images))
			self.statusbar.showMessage('Jumlah Folder: ' + str(self.dirs) + ', Jumlah Foto: ' + str(self.images))


	def evaluateDirectory(self, directory, strip = '-'):
		directory = str(directory)

		for file in os.listdir(directory):
			if file.lower().endswith('.jpg') or file.lower().endswith('.jpeg') or file.lower().endswith('.png'):
				self.logger(strip + ' Foto: ' + file)
				self.images += 1

		QtGui.QApplication.processEvents()

		for file in os.listdir(directory):
			if os.path.isdir(os.path.join(directory, file)):
				self.dirs += 1
				self.logger('=====================================')
				self.logger(strip + ' Folder: ' + file)
				self.evaluateDirectory(os.path.join(directory, file), strip + ' -')
				self.logger('=====================================')

		QtGui.QApplication.processEvents()


	def browseOutput(self):
		file = QtGui.QFileDialog.getSaveFileName(self)
		if file:
			if os.path.splitext(str(file))[1] != '.docx':
				file = file + '.docx'

			self.outputFolder.setText(file)
			self.logger('File Hasil: ' + file)


	def start(self):
		if self.inputFolder.text() == '' or self.outputFolder.text() == '':
			self.showDialog('error', 'Kesalahan!', 'Folder Sumber & File Hasil harus diisi')
			return
		elif self.images == 0:
			self.showDialog('error', 'Kesalahan!', 'Tidak ditemukan foto')
			return

		self.doc = Document()

		try:
			self.doc.save(str(self.outputFolder.text()))<commit_msg>file dialog<commit_after>#!C:\Python27\python.exe

import sys, os

from PyQt4 import QtCore, QtGui

from docx import Document
from docx.shared import Cm, Inches, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
from PIL import Image
from StringIO import StringIO

import dokumentasi_ui

Ui_Main = dokumentasi_ui.Ui_MainWindow

def main():
	app = QtGui.QApplication(sys.argv)
	window = Dokumentasi()
	window.show()
	sys.exit(app.exec_())

class Dokumentasi(QtGui.QMainWindow, Ui_Main):
	def __init__(self):
		super(Dokumentasi, self).__init__()
		self.setupUi(self)

		self.setWindowTitle('AutoDoc v1.1 - Karogis')
		self.logger('====================================')
		self.logger('||          *****            www.karogis.com            *****         ||')
		self.logger('====================================\n\n\n')

		self.logVisible = False
		self.toggleLog()

		self.statusbar.showMessage('Siap')
		self.btnInput.clicked.connect(self.browseInput)
		self.btnOutput.clicked.connect(self.browseOutput)
		self.btnExit.clicked.connect(self.close)
		self.btnStart.clicked.connect(self.start)
		self.btnLog.clicked.connect(self.toggleLog)


	def browseInput(self):
		directory = QtGui.QFileDialog.getExistingDirectory(self, 'Pilih Folder')
		if directory:
			self.inputFolder.setText(directory)
			self.logger('Folder Sumber: ' + directory)

			self.dirs = 0
			self.images = 0
			self.evaluateDirectory(directory)

			self.logger('Jumlah Folder: ' + str(self.dirs))
			self.logger('Jumlah Foto: ' + str(self.images))
			self.statusbar.showMessage('Jumlah Folder: ' + str(self.dirs) + ', Jumlah Foto: ' + str(self.images))


	def evaluateDirectory(self, directory, strip = '-'):
		directory = str(directory)

		for file in os.listdir(directory):
			if file.lower().endswith('.jpg') or file.lower().endswith('.jpeg') or file.lower().endswith('.png'):
				self.logger(strip + ' Foto: ' + file)
				self.images += 1

		QtGui.QApplication.processEvents()

		for file in os.listdir(directory):
			if os.path.isdir(os.path.join(directory, file)):
				self.dirs += 1
				self.logger('=====================================')
				self.logger(strip + ' Folder: ' + file)
				self.evaluateDirectory(os.path.join(directory, file), strip + ' -')
				self.logger('=====================================')

		QtGui.QApplication.processEvents()


	def browseOutput(self):
		file = QtGui.QFileDialog.getSaveFileName(self, 'Simpan Sebagai', '', 'Word Document (*.docx)')
		if file:
			self.outputFolder.setText(file)
			self.logger('File Hasil: ' + file)


	def start(self):
		if self.inputFolder.text() == '' or self.outputFolder.text() == '':
			self.showDialog('error', 'Kesalahan!', 'Folder Sumber & File Hasil harus diisi')
			return
		elif self.images == 0:
			self.showDialog('error', 'Kesalahan!', 'Tidak ditemukan foto')
			return

		self.doc = Document()

		try:
			self.doc.save(str(self.outputFolder.text()))
{'fraction_non_alphanumeric': 0.1935650378527185, 'fraction_numerical': 0.0036132140399174123, 'mean_word_length': 4.22751798561151, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3340169', 'n_tokens_mistral': 2213, 'n_tokens_neox': 1952, 'n_words': 357}