Skip to content

Commit

Permalink
2.1.5
Browse files Browse the repository at this point in the history
Bugfix: Fixed error when firstletter is typed manually into the template
Bugfix: Should no longer overwrite profiles on updates.
New: Added a script for startup. Disabled by default. When enabled it will organize every book in the library on startup.
New: Added fields First Issue Number and Last Issue Number.
  • Loading branch information
Stonepaw committed Jul 4, 2012
1 parent 3259359 commit fcbd4b6
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Package.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name=Library Organizer
Author=Stonepaw
Version=2.1.4
Version=2.1.5
Description=A file and folder organizer with GUI that helps build you file and folder paths.
Image=lopackagelogo.png
KeepFiles=losettingsx.dat
Expand Down
9 changes: 5 additions & 4 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
2.1.4
Bugfix: Periods at the end of folders paths are now removed.
Bugfix: Fixed error when running Library Organizer - Undo Last Move
Change: Library Organizer Quick will now give a warning and exit when Basefolder is empty.
2.1.5
Bugfix: Fixed error when firstletter is typed manually into the template
Bugfix: Should no longer overwrite profiles on updates.
New: Added a script for startup. Disabled by default. When enabled it will organize every book in the library on startup.
New: Added fields First Issue Number and Last Issue Number.
28 changes: 22 additions & 6 deletions configureform.py
Original file line number Diff line number Diff line change
Expand Up @@ -1877,9 +1877,25 @@ def create_calculated_insert_controls(self):
self.StartMonth.Name = "Start Month"
self._calculated_insert_controls_list["start month"] = self.StartMonth

self.FirstIssueNumber = InsertControlNumber()
self.FirstIssueNumber.Location = Point(4, 100)
self.FirstIssueNumber.Tag = self.FirstIssueNumber.Location
self.FirstIssueNumber.SetTemplate("firstissuenumber", "First Issue Number")
self.FirstIssueNumber.SetLabels("Prefix", "", "Suffix", "")
self.FirstIssueNumber.Name = "First Issue Number"
self._calculated_insert_controls_list["first issue number"] = self.FirstIssueNumber

self.LastIssueNumber = InsertControlNumber()
self.LastIssueNumber.Location = Point(4, 145)
self.LastIssueNumber.Tag = self.LastIssueNumber.Location
self.LastIssueNumber.SetTemplate("lastissuenumber", "Last Issue Number")
self.LastIssueNumber.SetLabels("Prefix", "", "Suffix", "")
self.LastIssueNumber.Name = "Last Issue Number"
self._calculated_insert_controls_list["last issue number"] = self.LastIssueNumber

self.FirstLetter = InsertControlFirstLetter()
self.FirstLetter.SetTemplate("first", "FirstLetter")
self.FirstLetter.Location = Point(4, 100)
self.FirstLetter.Location = Point(4, 190)
self.FirstLetter.Tag = self.FirstLetter.Location
self.FirstLetter.SetLabels("Prefix", "", "Suffix", "Field")
self.FirstLetter.Name = "First Letter"
Expand All @@ -1889,27 +1905,27 @@ def create_calculated_insert_controls(self):
self.Counter = InsertControlCounter()
self.Counter.SetTemplate("counter", "Counter")
self.Counter.SetLabels("Prefix", "", "Suffix", "Start", "Increment", "Pad")
self.Counter.Location = Point(4, 145)
self.Counter.Location = Point(4, 235)
self.Counter.Name = "Counter"
self.Counter.Tag = self.Counter.Location
self._calculated_insert_controls_list["counter"] = self.Counter

self.Read = InsertControlReadPercentage()
self.Read.SetTemplate("read", "Read %")
self.Read.SetLabels("Prefix", "", "Suffix", "Text", "Operator", "Percent")
self.Read.Location = Point(4, 190)
self.Read.Location = Point(4, 280)
self.Read.Tag = self.Read.Location
self.Read.Name = "Read Percentage"
self._calculated_insert_controls_list["read percentage"] = self.Read

#
# calculated_insert_controls_start_year_information
#
self._calculated_insert_controls_start_year_information.Location = System.Drawing.Point(225, 20)
self._calculated_insert_controls_start_year_information.Location = System.Drawing.Point(225, 10)
self._calculated_insert_controls_start_year_information.Name = "calculated_insert_controls_start_year_information"
self._calculated_insert_controls_start_year_information.Size = System.Drawing.Size(253, 35)
self._calculated_insert_controls_start_year_information.Size = System.Drawing.Size(253, 50)
self._calculated_insert_controls_start_year_information.TabIndex = 1
self._calculated_insert_controls_start_year_information.Text = "Start year and start month are calculated from the earliest issue of each series in your library."
self._calculated_insert_controls_start_year_information.Text = "Start year, start month, first issue number and last issue number are calculated from the available issues of each series in your library."

self._calculated_insert_controls.Controls.AddRange(System.Array[System.Windows.Forms.Control](self._calculated_insert_controls_list.Values))
self._calculated_insert_controls.Controls.Add(self._calculated_insert_controls_start_year_information)
Expand Down
9 changes: 9 additions & 0 deletions libraryorganizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ def LibraryOrganizerUndo(books):
MessageBox.Show(str(ex))


#@Name Library Organizer - Startup
#@Enabled false
#@Hook Startup
#@Image libraryorganizer.png
def LibraryOrganizerStartup():
books = ComicRack.App.GetLibraryBooks()
LibraryOrganizerQuick(books)


def show_config_form(profiles, lastused, books):
"""Shows the configure form and saves the changes if the user press okay.
Returns True if the user press Okay.
Expand Down
41 changes: 37 additions & 4 deletions lobookmover.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

import locommon

from locommon import Mode, get_earliest_book, name_to_field, field_to_name, check_metadata_rules, check_excluded_folders, UNDOFILE, UndoCollection
from locommon import Mode, get_earliest_book, name_to_field, field_to_name, check_metadata_rules, check_excluded_folders, UNDOFILE, UndoCollection, get_last_book

from loduplicate import DuplicateResult, DuplicateForm, DuplicateAction

Expand Down Expand Up @@ -1205,7 +1205,7 @@ class PathMaker(object):
"manga" : "Manga", "seriesComplete" : "SeriesComplete", "first" : "FirstLetter", "read" : "ReadPercentage",
"counter" : "Counter", "startmonth" : "StartMonth", "startmonth#" : "StartMonth", "colorist" : "Colorist", "coverartist" : "CoverArtist",
"editor" : "Editor", "inker" : "Inker", "letterer" : "Letterer", "locations" : "Locations", "penciller" : "Penciller", "storyarc" : "StoryArc",
"seriesgroup" : "SeriesGroup", "maincharacter" : "MainCharacterOrTeam"}
"seriesgroup" : "SeriesGroup", "maincharacter" : "MainCharacterOrTeam", "firstissuenumber" : "FirstIssueNumber", "lastissuenumber" : "LastIssueNumber"}

template_regex = re.compile("{(?P<prefix>[^{}<]*)<(?P<name>[^\d\s(>]*)(?P<args>\d*|(?:\([^)]*\))*)>(?P<postfix>[^{}]*)}")

Expand Down Expand Up @@ -1465,12 +1465,21 @@ def get_field_text(self, field, template_name, args_match):
elif field == "ReadPercentage" and len(args) == 3:
return self.insert_read_percentage(args)

elif field == "FirstLetter" and (args[0] in name_to_field or args[0] in field_to_name):
return self.insert_first_letter(args[0])
elif field == "FirstLetter":
if len(args) == 0:
return None
elif args[0] in name_to_field or args[0] in field_to_name:
return self.insert_first_letter(args[0])

elif field == "Counter" and len(args) == 3:
return self.insert_counter(args)

elif field == "FirstIssueNumber":
return self.insert_first_issue_number(args_match)

elif field == "LastIssueNumber":
return self.insert_last_issue_number(args_match)

#Yes/no fields can have 1 or 2 args
elif field in self.yes_no_fields and 0 < len(args) < 3:
return self.insert_yes_no_field(field, args)
Expand Down Expand Up @@ -1697,6 +1706,30 @@ def insert_start_month(self, args, template_name):
return ""


def insert_first_issue_number(self, padding):
"""
padding is the padding used, can be none.
"""
number = get_earliest_book(self.book).ShadowNumber

if padding is not None and padding.isdigit():
return self.replace_illegal_characters(self.pad(number, int(padding)))
else:
return self.replace_illegal_characters(number)


def insert_last_issue_number(self, padding):
"""
padding is the padding used, can be none.
"""
number = get_last_book(self.book).ShadowNumber

if padding is not None and padding.isdigit():
return self.replace_illegal_characters(self.pad(number, int(padding)))
else:
return self.replace_illegal_characters(number)


def insert_multi_value_field(self, field, args):
"""Gets the value from a multiple value field.
Expand Down
58 changes: 58 additions & 0 deletions locommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from cYo.Projects.ComicRack.Engine import MangaYesNo, YesNo

startbooks = {}
endbooks = {}

name_to_field = {"Age Rating" : "AgeRating", "Alternate Count" : "AlternateCount", "Alternate Number" : "AlternateNumber",
"Alternate Series" : "AlternateSeries", "Black And White" : "BlackAndWhite", "Characters" : "Characters", "Colorist" : "Colorist",
Expand Down Expand Up @@ -449,6 +450,11 @@ def get_earliest_book(book):
#Month is earlier
elif b.Month < startbook.Month:
startbook = b

#Month is the same so check for later issue numbers:
elif b.Month == startbook.Month:
if b.ShadowNumber < startbook.ShadowNumber:
startbook = b

#Store this final result in the dict so no calculation require for others of the series.
startbooks[index] = startbook
Expand All @@ -457,6 +463,58 @@ def get_earliest_book(book):



def get_last_book(book):
"""
Finds the last published issue of a series in the library.
Returns a ComicBook object.
"""
#Find the Earliest by going through the whole list of comics in the library find the earliest year field and month field of the same series and volume

index = book.Publisher+book.ShadowSeries+str(book.ShadowVolume)

if index in endbooks:
return endbooks[index]

endbook = book

for b in ComicRack.App.GetLibraryBooks():
if b.ShadowSeries == book.ShadowSeries and b.ShadowVolume == book.ShadowVolume and b.Publisher == book.Publisher:

#Notes:
#Year can be empty (-1)
#Month can be empty (-1)

#In case the initial value is bad
if endbook.ShadowYear == -1 and b.ShadowYear != 1:
startbook = b

#Check if the current book's year is later
if b.ShadowYear != -1 and b.ShadowYear > endbook.ShadowYear:
startbook = b

#Check if year the same and a valid month
if b.ShadowYear == endbook.ShadowYear and b.Month != -1:

#Current book has empty month
if endbook.Month == -1:
endbook = b

#Month is later
elif b.Month > endbook.Month:
endbook = b

#Month is the same so check for later issue numbers:
elif b.Month == endbook.Month:
if b.ShadowNumber > endbook.ShadowNumber:
endbook = b

#Store this final result in the dict so no calculation require for others of the series.
endbooks[index] = endbook

return endbook



def check_metadata_rules(book, profile):
"""Goes through the metadata rules and sees if the book should be moved or not.
Expand Down

0 comments on commit fcbd4b6

Please sign in to comment.