Commit b37ed88c authored by Denis Salem's avatar Denis Salem
Browse files

progress on process, add license

parent 16a08d06
This diff is collapsed.
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import base64
import codecs
import markdown
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import os
import time
import yaml
......@@ -25,7 +42,7 @@ def ExportAndRemoteCopy(argv=list()):
def ExportBlog(argv=list()):
''' Initialisation of environment '''
# Initialisation of environment
datastore = DataStore()
if len(argv) == 1:
......@@ -39,7 +56,7 @@ def ExportBlog(argv=list()):
if param[0] != "_": # marker to detect field names we do not want to replace
datastore.blogConfiguration[param] = ThemesDescriptor[argv[0]][param]
''' Now we want to preprocess entries'''
# Now we want to preprocess entries
processor = Processor(".:",":.","::")
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import datetime
import os
import shutil
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import os
import yaml
import codecs
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
from VenC.datastore.theme import ThemesDescriptor
from VenC.helpers import MsgFormat
from VenC.l10n import Messages;
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import ftplib
import socket
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import os
import yaml
......
#! /usr/bin/python
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
from VenC.datastore.configuration import GetBlogConfiguration
from VenC.datastore.entry import YieldEntriesContent
from VenC.datastore.entry import Entry
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import datetime
import os
import time
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import datetime
class MetadataNode:
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
from VenC.l10n import Messages
ThemesDescriptor = {
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import math
import base64
import datetime
......@@ -21,20 +38,24 @@ class VenCError(BaseException):
def __init__(self, msg):
self.msg = msg
# Some data printed out may exceed few lines so
# it's nicer to highlight specific part of the output
def HighlightValue(text, value, color="RED"):
return text.replace(
value,
MsgFormat[color]+value+MsgFormat["END"]
)
# Terminate nicely with notification
def Die(msg,color="RED"):
Notify(msg, color)
exit()
# Being verborse is nice, with colours it's better
def Notify(msg, color="GREEN"):
print(GetFormattedMessage(msg, color))
# Take care of setting up colours in printed out message
def GetFormattedMessage(msg, color="GREEN"):
return MsgFormat[color]+"\033[1mVenC: \033[0m"+MsgFormat[color]+msg+MsgFormat["END"]
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import locale
currentLocale = locale.getlocale()[0].split('_')[0]
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
class Messages:
blogCreated = "Your blog has been created!"
themeInstalled = "Theme has been installed!"
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
class Messages:
blogCreated = "Votre blog a été crée!"
themeInstalled = "Le thème à bien été installé!"
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import os
import pygments.lexers
import pygments.formatters
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
def For(self, argv):
outputString = str()
try:
......
#! /usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import cgi
import VenC.l10n
import VenC.helpers
......@@ -7,8 +24,8 @@ import VenC.helpers
from VenC.helpers import GetFormattedMessage
from VenC.helpers import HighlightValue
from VenC.l10n import Messages
from VenC.pattern.for import For
from VenC.pattern.for import RecursiveFor
from VenC.pattern.iterate import For
from VenC.pattern.iterate import RecursiveFor
class Processor():
def __init__(self, openSymbol, closeSymbol, separator):
......@@ -18,8 +35,6 @@ class Processor():
self.dictionnary = dict()
self.functions = dict()
self.functions["Get"] = self.Get
self.functions["For"] = For
self.functions["RecursiveFor"] = RecursiveFor
self.strict = True
self.currentStrings = dict()
self.currentString = str()
......@@ -83,21 +98,33 @@ class Processor():
True
)
def preProcess(self, inputIndex, string):
self.currentStrings[inputIndex] = str(string)
self.preProcessedStrings[inputIndex] = list()
self.patternsIndex[inputIndex] = list()
# ¹ Because parsing is recursive we wan't to avoid useless computation
# by splitting a given string and mark where exactly are the patterns
# we want to process.
#
# ² Some patterns are contextual while others are constant in time.
# To save time we wan't to perform two-pass analysis. In the first one
# we're ignoring some given patterns which usualy are contextual. Once
# non-contextual pattern are parsed the second pass occurs each time we
def preProcess(self, inputKey, string, ignore=list()):
self.ignore = ignore
self.preProcessedStrings[inputKey] = list()
self.patternsIndex[inputKey] = list()
closeSymbolPos = list()
openSymbolPos = list()
i = int()
while i < len(string):
if i + len(self.openSymbol) <= len(string) and string[i:i+len(self.openSymbol)] == self.openSymbol:
''' if i + len(self.openSymbol) <= len(string) and string[i:i+len(self.openSymbol)] == self.openSymbol: '''
if string[i:i+len(self.openSymbol)] == self.openSymbol:
openSymbolPos.append(i)
elif i + len(self.closeSymbol) <= len(string) and string[i:i+len(self.closeSymbol)] == self.closeSymbol:
''' elif i + len(self.closeSymbol) <= len(string) and string[i:i+len(self.closeSymbol)] == self.closeSymbol: '''
elif string[i:i+len(self.closeSymbol)] == self.closeSymbol:
closeSymbolPos.append(i)
# At some point, when we get the same opening and closing symbols, it means that we just reach the end of a pattern
# so we can do the real job.
if len(closeSymbolPos) == len(openSymbolPos) and len(closeSymbolPos) != 0 and len(openSymbolPos) != 0:
self.preProcessedStrings[inputIndex].append(string[i-closeSymbolPos[-1]:openSymbolPos[0]])
self.preProcessedStrings[inputIndex].append(string[openSymbolPos[0]:closeSymbolPos[-1]+len(self.closeSymbol)])
......@@ -107,34 +134,34 @@ class Processor():
openSymbolPos = list()
closeSymbolPos = list()
i=0
else:
i+=1
self.preProcessedStrings[inputIndex].append(string)
self.preProcessedStrings[inputKey].append(string)
def parse(self, inputIndex, escape=False):
if len(self.patternsIndex) == 0:
return self.currentStrings[inputIndex]
return self.preProcessedString[inputIndex][0]
output = str()
self.currentString = self.currentStrings[inputIndex]
for index in range(0,len(self.preProcessedStrings[inputIndex])):
if index in self.patternsIndex[inputIndex]:
output += self._process(self.preProcessedStrings[inputIndex][index], escape)
output += self.__process(self.preProcessedStrings[inputIndex][index], escape)
else:
output += self.preProcessedStrings[inputIndex][index]
return output
def _process(self, string, escape):
def __process(self, string, escape):
closeSymbolPos = list()
openSymbolPos = list()
output = str()
fields = list()
i = int()
while i < len(string):
if i + len(self.openSymbol) <= len(string) and string[i:i+len(self.openSymbol)] == self.openSymbol:
openSymbolPos.append(i)
......@@ -154,7 +181,7 @@ class Processor():
)
if escape:
return self._process(
return self.__process(
string[
:openSymbolPos[-1]]+
cgi.escape(output).encode(
......@@ -168,7 +195,7 @@ class Processor():
],
escape=True)
else:
return self._process(
return self.__process(
string[
:openSymbolPos[-1]]+
str(output)+
......
#!/usr/bin/python3
# Copyright 2016, 2017 Denis Salem
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
from setuptools import setup
import os
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment