Skip to content

Commit

Permalink
fix #9, fix #15
Browse files Browse the repository at this point in the history
  • Loading branch information
Dcosthephalump committed Jul 19, 2023
1 parent 250f8a5 commit 1417402
Show file tree
Hide file tree
Showing 14 changed files with 386 additions and 179 deletions.
133 changes: 71 additions & 62 deletions 01_selection.ipynb

Large diffs are not rendered by default.

252 changes: 198 additions & 54 deletions 02_information.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions davidAppL1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 1,
"id": "7360f520-2ce2-49ab-b5bc-29c09ce49e3b",
"metadata": {
"tags": []
Expand All @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 2,
"id": "4e5587ca-c13d-4728-b759-ce47a0389d9f",
"metadata": {
"tags": []
Expand Down Expand Up @@ -312,7 +312,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 3,
"id": "f9ba7365-b8b3-44a6-bc36-eea5e2092610",
"metadata": {
"tags": []
Expand All @@ -321,15 +321,15 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b21ede4d7dd14a3ab6b2bb0fff4d5412",
"model_id": "1a253c352c964dfc9fe36b7bc598c341",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Main(children=(GridspecLayout(children=(Select(layout=Layout(grid_area='widget001', height='auto', width='auto…"
]
},
"execution_count": 13,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
Binary file modified glyptodon/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file modified glyptodon/__pycache__/manuscriptFiles.cpython-311.pyc
Binary file not shown.
Binary file modified glyptodon/__pycache__/widgetCalls.cpython-311.pyc
Binary file not shown.
7 changes: 4 additions & 3 deletions glyptodon/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
'doc_host': 'https://Accessible-Data-and-Code.github.io',
'git_url': 'https://github.com/Accessible-Data-and-Code/glyptodon',
'lib_path': 'glyptodon'},
'syms': { 'glyptodon.information': { 'glyptodon.information.createTextWidgets': ( 'information.html#createtextwidgets',
'glyptodon/information.py')},
'syms': { 'glyptodon.information': {},
'glyptodon.manuscriptFiles': { 'glyptodon.manuscriptFiles.createManuscriptDirectory': ( 'manuscriptfiles.html#createmanuscriptdirectory',
'glyptodon/manuscriptFiles.py'),
'glyptodon.manuscriptFiles.currentManuscripts': ( 'manuscriptfiles.html#currentmanuscripts',
Expand All @@ -16,7 +15,9 @@
'glyptodon.manuscriptFiles.directoryNameClean': ( 'manuscriptfiles.html#directorynameclean',
'glyptodon/manuscriptFiles.py'),
'glyptodon.manuscriptFiles.saveImages': ( 'manuscriptfiles.html#saveimages',
'glyptodon/manuscriptFiles.py')},
'glyptodon/manuscriptFiles.py'),
'glyptodon.manuscriptFiles.updateMetadata': ( 'manuscriptfiles.html#updatemetadata',
'glyptodon/manuscriptFiles.py')},
'glyptodon.selection': { 'glyptodon.selection.Selection': ('selection.html#selection', 'glyptodon/selection.py'),
'glyptodon.selection.Selection.on_click_newMan': ( 'selection.html#selection.on_click_newman',
'glyptodon/selection.py'),
Expand Down
22 changes: 7 additions & 15 deletions glyptodon/information.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: ../02_information.ipynb.
# AUTOGENERATED! DO NOT EDIT! File to edit: ../05_pipeline.ipynb.

# %% auto 0
__all__ = ['createTextWidgets']
__all__ = []

# %% ../02_information.ipynb 4
# %% ../05_pipeline.ipynb 4
import ipywidgets as widgets
import param
import panel as pn
pn.extension('ipywidgets')

from .widgetCalls import *
import glyptodon.manuscriptFiles as mFil

# %% ../02_information.ipynb 6
def createTextWidgets():
textWidgets = []
metadata = ['Author','Work','Country','Language','City','Institution']

for data in metadata:
textWidgets.append(mFil.text(data))

return textWidgets
import glyptodon.widgetCalls as wc
from .manuscriptFiles import *
from .selection import *
from .information import *
57 changes: 52 additions & 5 deletions glyptodon/manuscriptFiles.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: ../manuscriptFiles.ipynb.

# %% auto 0
__all__ = ['createManuscriptDirectory', 'dictToList', 'directoryNameClean', 'saveImages', 'currentManuscripts']
__all__ = ['createManuscriptDirectory', 'dictToList', 'directoryNameClean', 'saveImages', 'currentManuscripts', 'updateMetadata']

# %% ../manuscriptFiles.ipynb 3
import os
Expand Down Expand Up @@ -65,21 +65,53 @@ def dictToList(thisdict:dict):

# %% ../manuscriptFiles.ipynb 11
def directoryNameClean(string):
# This function removes any of the illegal characters for directories
# This breaks a string down into individual words and
words = string.split()
upperWords = []
for word in words:
if word[0].isupper():
upperWords.append(word)
elif word.isalpha() == False:
upperWords.append(word)

string = ''
for word in upperWords:
string = string + word

# This loop removes any of the illegal characters for directories
illegalChars = ['\\','#','%','&','{','}','<','>','*','?','/',' ','$','!',"'",'"',':','@','+','`','|','=']

for char in illegalChars:
removalCount = 0
numChars = len(string)
for i in range(len(string)):
if string[i] == char:
string = string[:i] + string[i+1:]
removalCount = removalCount + 1

if numChars - removalCount - 1 == i:
break

# This loop removes any vowels in an overly long string
vowels = ['a','e','i','o','u']
if len(string) > 26:
for char in vowels:
removalCount = 0
numChars = len(string)
for i in range(len(string)):
if string[i] == char:
while string[i] == char:
string = string[:i] + string[i+1:]
removalCount = removalCount + 1

if numChars - removalCount - 1 == i:
break

if len(string) > 26:
string = string[0:26]

return string.lower()

# %% ../manuscriptFiles.ipynb 14
# %% ../manuscriptFiles.ipynb 15
def saveImages(files:dict, targetDirectory):
# This function saves content from memory into storage using the keys in the passed files dict (from a FileUpload widget)
# This
Expand All @@ -97,7 +129,7 @@ def saveImages(files:dict, targetDirectory):

os.chdir(baseDirectory)

# %% ../manuscriptFiles.ipynb 19
# %% ../manuscriptFiles.ipynb 20
def currentManuscripts():
# If this is run on any computer, it will have a unique file structure. This implementation works with that file structure.
baseDirectory = os.getcwd()
Expand Down Expand Up @@ -129,3 +161,18 @@ def currentManuscripts():

os.chdir(baseDirectory)
return manuscriptMetadata

# %% ../manuscriptFiles.ipynb 28
def updateMetadata(directory, information):
baseDirectory = os.getcwd()

for file in os.listdir(directory):
if file.endswith('.cfg'):
os.chdir(directory)
f = open(file, 'w')
printable = dictToList(information)
for data in printable:
print(data)
f.write(data + '\n')

os.chdir(baseDirectory)
20 changes: 15 additions & 5 deletions glyptodon/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def createManuscriptSelect():
selectionKey[selectionNames[-1]] = manuscript

manuscriptSelect = widgets.Select(options = selectionNames,
value = selectionNames[0],
value = 'Stavronikita Monastery Greek handwritten document Collection no.53',
rows = 10,
disabled = False,
layout = widgets.Layout(height = 'auto',
Expand All @@ -46,10 +46,20 @@ def createSelectionInfo():
class Selection(param.Parameterized):

newManClicked = False
selectedManuscript = None
# Set this to a default manuscript ASAP
selectedManuscript = ['/home/dc/glyptodon/manuscripts/stvrnktmnstrygrkcllctnn.53',
{'Work': 'Stavronikita Monastery Greek handwritten document Collection no.53',
'Author': '',
'Language': 'Greek',
'Country': 'Greece',
'City': 'Mount Athos',
'Institution': 'Stavronikita Monastery',
'Centuries': '14th Century'
}
]

# This is the output for the class
@param.output()
@param.output(('newManClicked', param.Boolean),('selectedManuscript', param.List))
def selectionOutput(self):
return self.newManClicked, self.selectedManuscript

Expand All @@ -63,7 +73,7 @@ def panel(self):
self.newMan.on_click(self.on_click_newMan)
self.selMan.on_click(self.on_click_selMan)

buttons = pn.Row(self.newMan, self.selMan)
buttons = pn.Row(self.selMan, self.newMan)

self.selectionKey, self.manuscriptSelect = createManuscriptSelect()

Expand All @@ -73,7 +83,7 @@ def panel(self):
# %% ../01_selection.ipynb 20
@patch
def on_click_selMan(self:Selection, null):
if self.selectedManuscript == None:
if len(self.selectedManuscript) == 0:
self.selectedManuscript = self.selectionKey[self.manuscriptSelect.value]
self.selMan.description = 'Select Different Manuscript'
else:
Expand Down
43 changes: 34 additions & 9 deletions manuscriptFiles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -700,22 +700,47 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 104,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"#| export\n",
"def updateMetadata(directory, information):\n",
" for root, dirs, files in os.walk(directory):\n",
" for file in files:\n",
" if file.endswith('.cfg'):\n",
" f = open(file, 'w')\n",
" \n",
" printable = dictToList(information)\n",
" for data in printable:\n",
" f.write(data + '\\n')"
" baseDirectory = os.getcwd()\n",
" \n",
" for file in os.listdir(directory):\n",
" if file.endswith('.cfg'):\n",
" os.chdir(directory)\n",
" f = open(file, 'w')\n",
" printable = dictToList(information)\n",
" for data in printable:\n",
" print(data)\n",
" f.write(data + '\\n')\n",
" \n",
" os.chdir(baseDirectory)"
]
},
{
"cell_type": "code",
"execution_count": 106,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"#| hide\n",
"\n",
"directory = '/home/dc/glyptodon/manuscripts/stvrnktmnstrygrkcllctnn.53'\n",
"information = {'Work': 'Stavronikita Monastery Greek handwritten document Collection no.53',\n",
" 'Author': 'Anonymous',\n",
" 'Language': 'Greek',\n",
" 'Country': 'Greece',\n",
" 'City': 'Mount Athos',\n",
" 'Institution': 'Stavronikita Monastery'}\n",
"\n",
"updateMetadata(directory, information)"
]
},
{
Expand Down
7 changes: 0 additions & 7 deletions manuscripts/data/data.cfg

This file was deleted.

7 changes: 0 additions & 7 deletions manuscripts/nicomacheanethics/nicomacheanethics.cfg

This file was deleted.

7 changes: 0 additions & 7 deletions manuscripts/republic/republic.cfg

This file was deleted.

1 comment on commit 1417402

@Dcosthephalump
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an update to several things: directoryNameClean and updateMetadata of manuscriptFiles, setting a default manuscript, and fixing the layout of Information a little bit

Please sign in to comment.