Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/CristianEdit/Globales.py
blob: 088748a156454a99f9f9e69adda116244c02dd55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
# -*- coding: utf-8 -*-

#   Globales.py por:
#   Cristian García <cristian99garcia@gmail.com>

import os
import commands

import gtksourceview2

lenguaje_manager = gtksourceview2.LanguageManager()
lenguajes = lenguaje_manager.get_language_ids()

estilo_manager = gtksourceview2.StyleSchemeManager()
estilos = estilo_manager.get_scheme_ids()

datos = os.path.expanduser('~/.cristianedit')
if not os.path.exists(datos):
    os.mkdir(datos)

configuracion = os.path.join(datos, 'configuracion.cfg')

if not os.path.exists(configuracion):

    f = open(configuracion, 'w')
    f.write('''[datos]
enumeracion = True
fuente = Monospace
margen = 80
is_margen =
ajuste = True
ajuste_palabras =
tabulador = 8
insertar_espacios =
sangria =
recientes =
tema = classic''')

    f.close()


def get_clasico():
    """Devuelve la posisión de classic en
    la lista de estilos"""

    cuenta = 0
    clasico = 0

    for estilo in estilos:
        if estilo == 'classic':
            clasico = cuenta

        cuenta += 1

    return clasico


def guardar_dato(cadena, dato, archivo):

    if dato:
        archivo.set('datos', cadena, dato)

    else:
        archivo.set('datos', cadena, '')


def get_mime_type(direccion, devolver=None):

    tipo = commands.getoutput('file %s --mime-type' % direccion).split(' ')[1]

    if devolver:
        return tipo

    if 'x-empty' in tipo or 'text' in tipo:
        return True

    return None