예제 #1
0
    def save_plugin_data(self, request=None):
        """Save plugin data.

        We want to save the generated lorem ipsum text for later use.
        Thus, although we don't show it to the user, in case when
        ``generate_lipsum`` field is set to True, we silently generate the
        text and save it into the plugin data.
        """
        if self.cleaned_data.get('generate_lipsum', None):
            lipsum_language = self.cleaned_data.get('lipsum_language', None)
            try:
                if lipsum_language in LANGUAGE_CHOICES_KEYS:
                    if lipsum_language == 'en':
                        gen = Generator()
                    else:
                        gen = TranslipsumGenerator(
                            language_code=lipsum_language)
                    text = gen.generate_paragraph()
                    truncator = Truncator(text)
                    self.cleaned_data['text'] = truncator.chars(
                        self.cleaned_data.get('lipsum_max_chars',
                                              DEFAULT_MAX_CHARS))
            except Exception as err:
                if DEBUG:
                    logger.debug(err)
 def test_20_translipsum_generator_ukrainian_cyrillic(self):
     """
     Testing the translipsum generator. Generating lorem ipsum sentence in Ukrainian Cyrillic.
     """
     g_uk = TranslipsumGenerator(language_code='uk')
     res = g_uk.generate_sentence()
     assert res
     return res
 def test_20_translipsum_generator_bulgarian_cyrillic(self):
     """
     Testing the translipsum generator. Generating lorem ipsum sentence in Bulgarian Cyrillic.
     """
     g_bg = TranslipsumGenerator(language_code='bg')
     res = g_bg.generate_sentence()
     assert res
     return res
 def __test_19_translipsum_generator_hebrew(self):
     """
     Testing the translipsum generator. Generating lorem ipsum sentence in Hebrew.
     """
     g_he = TranslipsumGenerator(language_code='he')
     res = g_he.generate_sentence()
     assert res
     return res
 def test_20_translipsum_generator_cyrillic(self):
     """
     Testing the translipsum generator. Generating lorem ipsum sentence in Cyrillic.
     """
     g_ru = TranslipsumGenerator(language_code='ru')
     res = g_ru.generate_sentence()
     assert res
     return res
 def test_18_translipsum_generator_greek(self):
     """
     Testing the translipsum generator. Generating lorem ipsum sentence in Greek.
     """
     g_el = TranslipsumGenerator(language_code='el')
     res = g_el.generate_sentence()
     assert res
     return res
 def test_17_translipsum_generator_georgian(self):
     """
     Testing the translipsum generator. Generating lorem ipsum sentence in Georgian.
     """
     g_ge = TranslipsumGenerator(language_code='ka')
     res = g_ge.generate_sentence()
     assert res
     return res
 def test_16_translipsum_generator_armenian(self):
     """
     Testing the translipsum generator. Generating lorem ipsum paragraphs in Armenian.
     """
     g_am = TranslipsumGenerator(language_code='hy')
     res = g_am.generate_paragraph()
     assert res
     return res
예제 #9
0
        u"abcdefghij",
        u"1234567890",
    )


registry.register(ExampleLanguagePack)

print '\nList of available (registered) languages after registering a new language pack \n---------------------------------------'
print get_available_language_codes()

print '\nTransliteration to Example\n---------------------------------------'
print translit(text, 'example')

print '\nTransliterated lorem ipsum generator \n---------------------------------------'
from transliterate.contrib.apps.translipsum import TranslipsumGenerator
g_am = TranslipsumGenerator(language_code='hy')

print 'Generating paragraphs'
print g_am.generate_paragraph()

g_ru = TranslipsumGenerator(language_code='ru')

print '\nGenerating sentenses'
print g_ru.generate_sentence()

print '\nLanguage detection\n---------------------------------------'
from transliterate.utils import detect_language

print detect_language(u'Լօրեմ իպսում դօլօր սիտ ամետ')

print detect_language(u'Лорем ипсум долор сит амет')
# How to setup: http://splinter.readthedocs.io/en/latest/drivers/chrome.html

# To run:
# pipenv install
# pipenv run python submit.py

import time
import random
from transliterate import translit, get_available_language_codes
from transliterate.contrib.apps.translipsum import TranslipsumGenerator
from splinter import Browser
import os

# Randomly select a language. Remove ", reversed=True" to test other language characters.
lorem = TranslipsumGenerator(language_code=random.choice(
    get_available_language_codes()),
                             reversed=True)

# Current working dirrectory
dir_path = os.getcwd()

########### SET config section ###########

# Set IMAGE: File path(s) need to be absolute
supplimental_file = dir_path + '/Example_ETD.jpg'
lg_img_file = dir_path + '/Example_ETD.tiff'

# Set PDF: Folder to look for pdfs
path_to_PDFs = (dir_path)

# Set URL:
예제 #11
0
# ChromeDriver under FreeBSD https://stackoverflow.com/questions/9861830/chromedriver-under-freebsd
# Please note that if you prefer to use Firefox you will need to install Gekodriver https://github.com/mozilla/geckodriver/releases
# How to setup: http://splinter.readthedocs.io/en/latest/drivers/chrome.html
# To run: pipenv run python submit.py


import time
import random
from transliterate import translit, get_available_language_codes
from transliterate.contrib.apps.translipsum import TranslipsumGenerator
from splinter import Browser
import os

# Randomly select a language. EN will cause errors at this time.
languages = ['el', 'hy', 'ka', 'ru']
lorem = TranslipsumGenerator(language_code=random.choice(languages))

# Current working dirrectory
dir_path = os.getcwd()

########### SET config section ###########

# Set IMAGE: File path(s) need to be absolute
supplimental_file = dir_path + '/Example_ETD.jpg'

# Set PDF: Folder to look for pdfs
path_to_PDFs = (dir_path)

# Set URL:
#url = "http://dlhost1.lib.utk.edu/user/"
url = "http://localhost:8000/user/"