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

Remove entry splitter

parent 6797e3e8
......@@ -14,10 +14,24 @@ la publication elle-même.
Il est aussi possible d'utiliser ceux-là dans des templates. Pour en savoir plus sur les templates, rendez vous [ici](.:GetRelativeOrigin:.Les-templates)
## .:Escape:: .:GetEntryContent:. ::EndEscape:.
Ce pattern ne peut pas être utilisé dans un template.
Ce pattern renvoie le contenu complet de la publication courante.
## .:Escape:: .:GetEntryPreview:. ::EndEscape:.
Ce pattern ne peut pas être utilisé dans un template.
Ce pattern renvoie le résumé de la publication courante.
## .:Escape:: .:GetEntryID:. ::EndEscape:.
Retourne l'identifiant unique de la publication.
Retourne l'identifiant unique de la publication.
## .:Escape:: .:GetEntryTitle:. ::EndEscape:.
Retourne le nom de la publication.
## .:Escape:: .:GetEntryMonth:. ::EndEscape:.
......@@ -27,12 +41,14 @@ Retourne le mois de création de la publication.
Retourne l'année de création de la publication.
## .:Escape:: .:GetEntryDay:. ::EndEscape:.
Retourne le jour de création de la publication.
## .:Escape:: . :GetEntryHour:. ::EndEscape:.
Retourne l'heure de création de la publication.
## .:Escape:: .:GetEntryMinute:. ::EndEscape:.
Retourne la minute de création de la publication.
## .:Escape:: .:GetEntryDate[::format]:. ::EndEscape:.
......
......@@ -101,3 +101,33 @@ Petites particularités de VenC :
- Il est conçu pour GNU/Linux spécifiquement.
- C'est un logiciel libre sous licence [GNU/GPLv3](https://www.gnu.org/licenses/gpl-3.0.fr.html).
# Quand ça tiens sur une disquette, c'est quand même mieux
En l'état, les chiffres nous disent que:
- Le code source applicatif pèse moins de 300Ko
- Les assets constitués pour l'essentiel des thèmes pèse moins de 900Ko.
Ce que ça signifie c'est qu'il y a peu de code.
En particulier pour le code applicatif écrit en Python.
Il y a au moins deux conséquences positives :
- VenC est plus facile à maintenir parce qu'il y a moins de chose à lire et à comprendre.
- La vitesse d'exécution bénéficie de la petite taille du code source, parce qu'il y a
moins de code à exécuter et à interpréter.
## Quand est-il des librairies tierces ?
Là dessus nous n'avons malheureusement pas le contrôle. Ce que nous pouvons faire
cependant c'est réaliser des choix judicieux dans ce qu'il convient de réimplémenter
et ce qu'il convient d'importer. Nous avons fait le choix de développer notre
propre microcode pour le formatage des thèmes de VenC. VenC ne dépend donc pas
d'un moteur de template tier comme [Jinja](https://jinja.palletsprojects.com/en/3.0.x/) et
voit ses performances amélioriées dans la mesure où le moteur de template interne
à VenC est fortement couplé avec le reste du code et a bénéficié d'un effort
d'optimisations substantiel.
Dans les futurs version de VenC, pour minimiser le nombre de composant installé
sur votre machine, nous ferons en sorte que certaines dépendances soient optionnels.
Et ouais, parce qu'on est pas là non plus pour dégueulasser votre box !
......@@ -169,3 +169,11 @@ dans le fichier de configuration principal et, si c'est le cas, quelle en est la
si elle n'est pas définie. Si le second argument est absent, le motif est ignoré et supprimé.
Ce motif n'a pas de variable contextuelle.
## .:Escape:: .:PreviewIfInThreadElseContent:. ::EndEscape:.
Ce pattern ne peut être utilisé que dans le _chunk_ __entry.html__.
Il renvoie le résumé de la publication courante si VenC génère la
page dans un fil de publication. Sinon, VenC renvoie le
contenu complet de la publication courante.
......@@ -45,17 +45,19 @@ __à l'intérieur__ d'un ou plusieurs arguments_.
<a href=".:GetChapterAttributeByIndex::path::5.2.2:.#escape-getchaptersopen_nodeopen95branchclose95branchclose95node-endescape">GetChapters</a>::open_node, open_branch, close_branch, clode_node::index, level, title, path::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.2:.#escape-getchapterattributebyindexattributeindex-endescape">GetChapterAttributeByIndex</a>::attribute, index:: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.5:.#escape-getembedcontentcontent_url-endescape">GetEmbedContent</a>::content_url:: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.2:.#escape-getentryattributebyidattributeidentifier-endescape">GetEntryAttributeByID</a>::attribute, identifier:: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentrycontent-endescape">GetEntryContent</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentrydate-endescape">GetEntryDate</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentrydateurl-endescape">GetEntryDateURL</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentryday-endescape">GetEntryDay</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentryhour-endescape">GetEntryHour</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentryid-endescape">GetEntryID</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.2:.#escape-getentryattributebyidattributeidentifier-endescape">GetEntryAttributeByID</a>::attribute, identifier:: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentrymetadatametadata_name-endescape">GetEntryMetadata</a>::metadata_name:: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentrymetadataifexistsmetadata_namestringstring2-endescape">GetEntryMetadataIfExists::metadata_name,string,string2::value::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentrymetadataifnotnullmetadata_namestringstring2-endescape">GetEntryMetadataIfNotNull</a>::metadata_name, string, string::value::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentryminute-endescape">GetEntryMinute</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentrymonth-endescape">GetEntryMonth</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentrypreview-endescape">GetEntryPreview</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentrytitle-endescape">GetEntryTitle</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentryurl-endescape">GetEntryURL</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-getentryyear-endescape">GetEntryYear</a>:: :: ::NewLine::
......@@ -90,6 +92,7 @@ __à l'intérieur__ d'un ou plusieurs arguments_.
<a href=".:GetChapterAttributeByIndex::path::5.3.3:.#escape-latex2mathmllatex_code-endescape">Latex2MathML</a>::latex_code:: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.2:.#escape-leavesforblogcategoriesstringseparator-endescape">LeavesForBlogCategories</a>::string, separator::value, path, branch::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.2.1:.#escape-leavesforentrycategoriesstringseparator-endescape">LeavesForEntryCategories</a>::string, separator::value, path, branch::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.3.1:.#escape-previewifinthreadelsecontent-endescape">PreviewIfInThreadElseContent</a>:: :: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.3.3:.#escape-setcolorinput_textcolor-endescape">SetColor</a>::input_text, color:: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.3.3:.#escape-setstyletag95idtag95classcontent-endescape">SetStyle</a>::tag_id, tag_class, content:: ::NewLine::
<a href=".:GetChapterAttributeByIndex::path::5.3.3:.#escape-tableitem1item2-endescape">Table</a>::item1, item2, ... :: ::NewLine::
......
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.venc_source_Text .hll { background-color: #ffffcc }
.venc_source_Text { background: #f8f8f8; }
.venc_source_Text .c { color: #408080; font-style: italic } /* Comment */
.venc_source_Text .err { border: 1px solid #FF0000 } /* Error */
.venc_source_Text .k { color: #008000; font-weight: bold } /* Keyword */
......
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.venc_source_Yaml .hll { background-color: #ffffcc }
.venc_source_Yaml { background: #f8f8f8; }
.venc_source_Yaml .c { color: #408080; font-style: italic } /* Comment */
.venc_source_Yaml .err { border: 1px solid #FF0000 } /* Error */
.venc_source_Yaml .k { color: #008000; font-weight: bold } /* Keyword */
......
......@@ -6,7 +6,7 @@
</tr>
<tr>
<td>VenC est léger! Ça tiens sur une disquette! On vous explique pourquoi c'est cool!</td>
<td><a href=".:GetRelativeOrigin:..:GetChapterAttributeByIndex::path::1:.#quand-ca-tiens-sur-une-disquette-cest-quand-meme-mieux" lang=".:GetBlogLanguage:.">VenC est léger! Ça tiens sur une disquette! On vous explique pourquoi c'est cool!</a></td>
<td><img src="venc_is_compact.png" ></td>
</tr>
<tr>
......
<div id="entry-content">
<div id="entry-content">
<div class="entry" id="entry.:GetEntryID:." data-venc-keywords=".:ForEntryTags::{value}::,:." data-venc-authors=".:ForEntryAuthors::{value}::,:.">
.:GetEntryMetadataIfExists::banner::
<div class="entry-banner" style="background-image: url('.:GetRelativeOrigin:.{value}');">
......@@ -10,4 +10,3 @@
.:GetEntryContent:.
</div>
</div>
......@@ -177,9 +177,13 @@
DONE | Add definition in documentation for optional fields in blog configuration.
# version 2.0.1
DONE| (issue #20) Calling pattern in wrong context should trigger explicit error instead of UnknownPattern
DONE | (issue #20) Calling pattern in wrong context should trigger explicit error instead of UnknownPattern.
# version 2.0.x
# version 2.0.2
DONE | Fix for_entry_metadata; catching unavailable contextual pattern.
DONE | Fix github issue #21. Add missing documentation about GetEntryContent, GetEntryPreview and PreviewIfInThreadElseContent.
# version 2.0.0
WIP | Add relevant templates for themes.
WIP | Client-side search engine.
......
......@@ -87,7 +87,7 @@ extra_files.append(
setup(
name='VenC',
version='2.0.1',
version='2.0.2',
description='A static blog generator.',
author='Denis Salem',
author_email='denissalem@tuxfamily.org',
......
......@@ -17,4 +17,4 @@
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
venc_version = "2.0.1"
venc_version = "2.0.2"
......@@ -144,19 +144,16 @@ def process_non_contextual_patterns(pattern_processor, theme, patterns_map):
entry.content.process_markup_language(markup_language)
entry.html_wrapper = deepcopy(theme.entry)
for pp in [entry.html_wrapper.above, entry.html_wrapper.below]:
pattern_processor.process(pp)
pp.replace_needles()
pattern_processor.process(entry.html_wrapper.processed_string)
entry.html_wrapper.processed_string.replace_needles()
entry.rss_wrapper = deepcopy(theme.rss_entry)
for pp in [entry.rss_wrapper.above, entry.rss_wrapper.below]:
pattern_processor.process(pp)
pp.replace_needles()
pattern_processor.process(entry.rss_wrapper.processed_string)
entry.rss_wrapper.processed_string.replace_needles()
entry.atom_wrapper = deepcopy(theme.atom_entry)
for pp in [entry.atom_wrapper.above, entry.atom_wrapper.below]:
pattern_processor.process(pp)
pp.replace_needles()
pattern_processor.process(entry.atom_wrapper.processed_string)
entry.atom_wrapper.processed_string.replace_needles()
for pattern_name in patterns_map.non_contextual["entries"].keys():
pattern_processor.del_function(pattern_name)
......
......@@ -901,10 +901,13 @@ class DataStore:
if not len(argv[2]):
argv[2] = ' '
try:
entry.html_for_metadata[key] = argv[2].join([
argv[1].format(**{"value": item.strip()}) for item in l
])
entry.html_for_metadata[key] = argv[2].join([
argv[1].format(**{"value": item.strip()}) for item in l
])
except KeyError as e:
raise GenericMessage(messages.unknown_contextual.format(e))
return entry.html_for_metadata[key]
......
......@@ -36,26 +36,27 @@ from venc2.patterns.exceptions import IllegalUseOfEscape
class EntryWrapper:
def __init__(self, wrapper, filename):
self.patterns = [".:GetEntryContent:.", ".:GetEntryPreview:.", ".:PreviewIfInThreadElseContent:."]
for pattern in self.patterns:
try:
w = wrapper.split(pattern)
if len(w) > 2:
die(messages.too_much_call_of_content.format(filename))
for p in self.patterns:
if p in w[0] or p in w[1]:
die(messages.too_much_call_of_content.format(filename))
self.above = ProcessedString(w[0], filename, True)
self.below = ProcessedString(w[1], filename, True)
self.required_content_pattern = pattern
return
except IndexError:
pass
pattern_replacement = {
".:GetEntryContent:." : "---VENC-GET-ENTRY-CONTENT---",
".:GetEntryPreview:." : "---VENC-GET-ENTRY-PREVIEW---",
".:PreviewIfInThreadElseContent:." : "---VENC-PREVIEW-IF-IN-THREAD-ELSE-CONTENT---"
}
self.content_type_flag = 0
wrapper_len = len(wrapper)
self.process_get_entry_content = 1 if ".:GetEntryContent:." in wrapper else 0
self.process_get_entry_preview = 1 if ".:GetEntryPreview:." in wrapper else 0
if ".:PreviewIfInThreadElseContent:." in wrapper:
self.process_get_entry_content = 1
self.process_get_entry_preview = 1
die(messages.missing_entry_content_inclusion.format(filename))
for content_pattern in pattern_replacement.keys():
wrapper = wrapper.replace(content_pattern, pattern_replacement[content_pattern])
if len(wrapper) == wrapper_len:
die(messages.missing_entry_content_inclusion.format(filename))
self.processed_string = ProcessedString(wrapper, filename, True)
class Entry:
def __init__(self, filename, paths, jsonld_callback, date_format, encoding="utf-8", ):
......
......@@ -60,7 +60,7 @@ class Messages:
recursive_for_unknown_value="RecursiveFor: Value {0} isn't defined."
not_enough_args="Missing arguments (expected {0}, got {1})."
unknown_pattern="The pattern '{0}'doesn't exists or isn't used in the right place."
unknown_contextual="Contextual variable {0} doesn't exists."
unknown_contextual="Contextual variable {0} doesn't exists or is not available here."
in_ressource="In ressource '{0}'."
something_goes_wrong_return_empty_string="An error occurs. Replacement with an empty string."
arg_blog_name="Blog name {0}"
......
......@@ -58,7 +58,7 @@ class Messages:
recursive_for_unknown_value="RecursiveFor: La valeur {0} n'existe pas."
not_enough_args="Paramétres manquants (attendus {0}, reçus {1})."
unknown_pattern="Le motif '{0}' n'existe pas ou n'est pas utilisé au bon endroit."
unknown_contextual="La variable contextuel {0} n'existe pas."
unknown_contextual="La variable contextuel {0} n'existe pas ou n'est pas disponible ici."
in_ressource="Dans la ressource '{0}'."
something_goes_wrong_return_empty_string="Une erreur s'est produite. Remplacement pas une chaine de caractère vide."
arg_blog_name="Nom du blog {0}"
......
......@@ -209,6 +209,8 @@ class ProcessedString():
self.len_close_pattern_pos = len(self.close_pattern_pos)
if self.len_open_pattern_pos != self.len_close_pattern_pos:
print(string)
print(self.len_open_pattern_pos,self.len_close_pattern_pos)
raise MalformedPatterns(self.len_open_pattern_pos > self.len_close_pattern_pos, False, ressource)
self.string = string
......
......@@ -370,27 +370,40 @@ class Thread:
def do_iteration(self, entry):
global current_source
current_source = getattr(entry, self.content_type+"_wrapper").above
self.processor.process(current_source, safe_process = True)
self.columns[self.columns_counter] += current_source.string
current_source.restore()
entry_wrapper = getattr(entry, self.content_type+"_wrapper")
if (entry.html_wrapper.required_content_pattern == ".:GetEntryPreview:.") or (entry.html_wrapper.required_content_pattern == ".:PreviewIfInThreadElseContent:." and self.in_thread):
current_source = entry.preview
else:
current_source = entry.content
self.processor.process(current_source, safe_process = True)
self.columns[self.columns_counter] += current_source.string
current_source.restore()
current_source = getattr(entry, self.content_type+"_wrapper").below
self.processor.process(current_source, safe_process = True)
self.columns[self.columns_counter] += current_source.string
current_source.restore()
preprocessed_wrapper = getattr(entry, self.content_type+"_wrapper").processed_string
self.processor.process(preprocessed_wrapper, safe_process = True)
output=preprocessed_wrapper.string
if entry_wrapper.process_get_entry_content:
self.processor.process(entry.content, safe_process = True)
output=output.replace(
"---VENC-GET-ENTRY-CONTENT---",
entry.content.string
)
if entry_wrapper.process_get_entry_preview:
self.processor.process(entry.preview, safe_process = True)
output=output.replace(
"---VENC-GET-ENTRY-PREVIEW---",
entry.preview.string
)
output=output.replace(
"---VENC-PREVIEW-IF-IN-THREAD-ELSE-CONTENT---",
entry.preview.string if self.in_thread else entry.content.string
)
self.columns[self.columns_counter] += output
preprocessed_wrapper.restore()
if entry_wrapper.process_get_entry_content:
entry.content.restore()
if entry_wrapper.process_get_entry_preview:
entry.preview.restore()
self.columns_counter +=1
if self.columns_counter >= self.columns_number:
self.columns_counter = 0
......
#! /usr/bin/env python3
# Copyright 2016, 2020 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/>.
# This code is a draft
import sys
import json
from bokeh.plotting import figure, output_file, save
data = json.load(open(sys.argv[1], "r"))
p = figure(title="Benchmark: VenC")
p.xaxis.axis_label = "Entries count"
p.yaxis.axis_label = "Time"
step = 5
p.line(
[c*step for c in range(0, len(data["benchmark_data"]["VenC"]))],
[v["time"] for v in data["benchmark_data"]["VenC"] ],
color="#000000",
legend_label = "VenC "+ data["environment"]["VenC"]
)
p.line(
[c*step for c in range(0, len(data["benchmark_data"]["VenC"]))],
[v["time_internal"] for v in data["benchmark_data"]["VenC"] ],
color="#808080",
legend_label = "VenC"+ data["environment"]["VenC"]+" (internal")
)
p.legend.location = "top_left"
output_file("benchmark.html", title="")
save(p)
#! /usr/bin/env python3
# Copyright 2016, 2020 Denis Salem
# Copyright 2016, 2021 Denis Salem
#
# This file is part of VenC.
#
......@@ -20,14 +20,11 @@
import datetime
import os
import random
import shutil
import subprocess
import sys
stdout = sys.stdout
devnull = open(os.devnull, "w")
ENVIRONMENT = {}
BENCHMARCH_VERSION = "1.0.0"
BENCHMARCH_VERSION = "2.0.2"
CONTEXT = {
"SAMPLE_CATEGORIES" : ["Movie","Computing","Music","Art","Sport","Literature","Diary","Photography","Science"],
......@@ -36,6 +33,9 @@ CONTEXT = {
"ENTRY_ID_COUNTER" : 0,
"DATETIME" : datetime.datetime(2000, 1, 1, 0, 0).timestamp(),
}
ENVIRONMENT = {}
LOREM_IPSUM = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sodales, dui ultrices interdum tincidunt, nibh tortor varius arcu, vitae fermentum velit nisl vel elit. Donec at lorem semper, pellentesque velit in, sodales metus. Fusce tempus arcu sit amet dui luctus, id rhoncus augue iaculis. Maecenas laoreet odio sit amet mauris porttitor feugiat. Aliquam nec elit congue, eleifend purus vitae, hendrerit felis. Proin vitae condimentum quam. Praesent suscipit nisl est, ac semper mauris eleifend et. Duis neque lorem, pharetra ut facilisis ac, rutrum et mauris. Pellentesque facilisis ex in metus semper vulputate. Vivamus ultrices justo et eros molestie, quis hendrerit tellus sollicitudin. Aenean id nisl a lacus finibus ullamcorper.
Cras auctor, dolor ut elementum vulputate, lectus arcu luctus turpis, quis laoreet augue dolor ac ex. Suspendisse molestie vestibulum erat, ut congue neque elementum et. Fusce nisl nulla, blandit ac sapien sed, vehicula vestibulum neque. Ut sit amet elementum urna. Vivamus bibendum commodo sem vel tempor. Donec nec magna sed diam ullamcorper pretium a ut felis. Phasellus elementum aliquet tempor. Proin quis orci non est mollis blandit sit amet vitae neque.
Aenean urna lacus, interdum ultricies arcu quis, laoreet venenatis orci. Integer mollis massa nec ipsum dignissim, eget vehicula nibh tristique. Cras sagittis sem in ornare tristique. Donec rhoncus massa et sem laoreet viverra. Aenean ultrices, tellus id placerat ultrices, arcu arcu venenatis justo, nec fringilla libero velit sit amet nulla. Mauris convallis sed purus ac consectetur. Fusce accumsan, arcu eget dignissim gravida, justo justo blandit felis, at ultrices ligula quam ac mi. Nulla facilisi. Curabitur erat tortor, molestie vitae sem ut, finibus iaculis risus. Aenean consequat laoreet leo, id auctor neque elementum sed. Etiam ante est, bibendum id dictum non, convallis sit amet ante. Aliquam tortor sem, venenatis vel euismod sed, egestas sit amet nulla. Maecenas magna ipsum, pretium sit amet urna id, tincidunt molestie sapien. Maecenas laoreet lobortis vehicula.
......@@ -57,28 +57,60 @@ Vivamus posuere sollicitudin odio at pulvinar. Aenean a ornare sapien. Mauris co
Sed a magna non magna blandit tristique sed quis augue. Donec lobortis tempus dui vel aliquam. Aliquam leo metus, malesuada in interdum sed, ultricies sit amet eros. Integer luctus ante vel arcu volutpat, vel rhoncus quam commodo. Morbi dapibus eleifend nisl, a vehicula lacus tincidunt vel. Ut molestie fermentum orci, eget eleifend nisi aliquet imperdiet. Vivamus aliquet blandit lectus vitae tincidunt. Donec maximus augue sed ex euismod convallis.
Cras ultrices orci erat, lobortis mollis est pellentesque ut. Morbi convallis consequat massa, vitae interdum lorem. Sed libero velit, commodo a varius eu, convallis in leo. Phasellus quis justo venenatis, semper mi sit amet, gravida mi. In pharetra ipsum a dolor rhoncus accumsan. Sed diam velit, tempus non massa ut, semper pellentesque sem. Suspendisse sagittis, nulla sed sagittis blandit, dolor erat lobortis sem, et elementum mi urna at dui. Duis felis lacus, malesuada sit amet enim ac, egestas malesuada orci. Duis iaculis erat quam, vel fermentum dui pretium quis. Praesent a lectus sem. Nullam est nulla, convallis at sodales et, sodales at nisi."""
def set_python_version():
if not "Python" in ENVIRONMENT.keys():
ENVIRONMENT["Python"] = sys.version.replace('\n', '')
def be_quiet(fun, args):
quiet = not "-v" in sys.argv
if quiet:
sys.stdout = devnull
PATH_TO_VENC = os.path.expanduser("~")+"/.local/bin/venc"
def clear_venc_blog():
try:
shutil.rmtree("venc-benchmark")
fun(args)
if quiet:
sys.stdout = stdout
except FileNotFoundError:
pass
def gen_venc_entry():
ID = CONTEXT["ENTRY_ID_COUNTER"]
entry = "title: benchmark entry "+str(ID)+'\n'
entry += "authors: VenC Comparative Benchmark\n"
entry += "categories: "+CONTEXT["SAMPLE_CATEGORIES"][CONTEXT["CATEGORY_INDEX"]]+'\n'
entry += "tags: ''"
entry += "---VENC-BEGIN-PREVIEW---\n"
entry += "---VENC-END-PREVIEW---\n"+(LOREM_IPSUM*CONTEXT["CONTENT_SIZE_MULTIPLIER"])
date = datetime.datetime.fromtimestamp(CONTEXT["DATETIME"])
entry_date = str(date.month)+'-'+str(date.day)+'-'+str(date.year)+'-'+str(date.hour)+'-'+str(date.minute)
output_filename = str(ID)+"__"+entry_date+"__"+"benchmark_entry_"+str(ID)
open("venc-benchmark/entries/"+output_filename, 'w').write(entry)
def get_command_output(argv):
output = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr= devnull if not "-v" in sys.argv else sys.stderr)
output = subprocess.Popen(argv, STDOUT=subprocess.PIPE, stderr= DEVNULL if not "-v" in sys.argv else sys.stderr)
output.wait()
return output.stdout.read().decode("utf-8").strip()
def init_entries():
for i in range(0, 1000):
gen_venc_entry()
update_context()
def init_venc_blog():
from venc2.commands.new import new_blog
from venc2 import venc_version
print("Benckmark VenC", venc_version)
ENVIRONMENT["VenC"] = venc_version
clear_venc_blog()
new_blog(["venc-benchmark"])
from distutils.dir_util import copy_tree
copy_tree("venc-benchmark-config", "venc-benchmark")
def set_python_version():
proc = subprocess.Popen("cat /proc/cpuinfo | grep \"model name\" | head -1 | cut -d ':' -f 2", shell=True, stdout = subprocess.PIPE, stderr = subprocess.PIPE, encoding = 'utf8')
ENVIRONMENT["CPU"] = proc.stdout.read().strip()
ENVIRONMENT["Python"] = sys.version.replace('\n', '')
def update_context():
global CONTEXT
CONTEXT["ENTRY_ID_COUNTER"] += 1
CONTEXT["DATETIME"] += 86400
CONTEXT["CONTENT_SIZE_MULTIPLIER"] = random.randint(0,5)
CONTEXT["CATEGORY_INDEX"] = random.randint(0, 8)
set_python_version()
init_venc_blog()
init_entries()
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