/usr/lib/python3/dist-packages/ukui_menu/easyfiles.py is in ukui-menu 1.1.3-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | # -*- coding: utf-8 -*-
# Copyright (C) 2007-2014 Clement Lefebvre <root@linuxmint.com>
# Copyright (C) 2015 Martin Wimpress <code@ubuntu-mate.org>
# Copyright (C) 2016,Tianjin KYLIN Information Technology Co., Ltd.
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
import os
import os.path
import urllib.request, urllib.parse, urllib.error
"""
def TestForDir(dirname):
if not os.path.exists( os.path.join(os.path.expanduser("~"), dirname ) ):
os.makedirs( os.path.join( os.path.expanduser("~"), dirname) )
def TestForFiles(filename):
if not os.path.exists( os.path.join( os.path.expanduser("~"), filename ) ):
file = open( os.path.join( os.path.expanduser("~"), filename ),"w")
file.close()
def FileExists(f):
return os.path.exists(f)
"""
def GetFilePath(uri):
path = urllib.request.url2pathname(uri) # escape special chars
path = path.strip('\r\n\x00') # remove \r\n and NULL
# get the path to file
if path.startswith('file://'): # nautilus, rox
path = path[7:] # 7 is len('file://')
return path
"""
def ParseDesktopFile(DFile):
# Get the locale
lang = os.getenv("LANG")
if lang:
langArray = lang.split("_")
else:
langArray = [ None ]
locale = langArray[0] or ""
localeName = "Name[" + locale + "]="
localeComment = "Comment[" + locale + "]="
localeGenericName = "GenericName[" + locale + "]="
PlaceName=PlaceComment=PlaceExec=PlaceIconName=GenericName=TerminalName=""
FileData = []
if FileExists(GetFilePath(DFile))==True:
parseData = False
openfile = open(GetFilePath(DFile), 'r')
datalist = openfile.readlines()
openfile.close()
for i in datalist:
i = i.strip('\r\n\x00')
if len(i) != 0:
if i[0] == "[" and i[-1] == "]":
parseData = "[Desktop Entry]" == i
elif parseData:
if i[0:5] == "Name=":
PlaceName = i[5:]
elif i[0:9] == localeName:
PlaceName = i[9:]
elif i[0:8] == "Comment=":
PlaceComment = i[8:]
elif i[0:12] == localeComment:
PlaceComment = i[12:]
elif i[0:5] == "Exec=":
PlaceExec = i[5:]
elif i[0:5] == "Icon=":
PlaceIconName = i[5:]
elif i[0:12] == "GenericName=":
GenericName = i[12:]
elif i[0:16] == localeGenericName:
GenericName = i[16:]
elif i[0:9] == "Terminal=":
TerminalName = i[9:]
FileData.append(PlaceName)
FileData.append(PlaceComment)
FileData.append(PlaceExec)
FileData.append(PlaceIconName)
FileData.append(GenericName)
FileData.append(TerminalName)
return FileData
return None
def WriteListFile(ListToAdd,ItemToAdd,mode):
RecentapplicationsFile = open (os.path.join(os.path.expanduser("~"), ListToAdd),"r")
RecentapplicationsList = RecentapplicationsFile.readlines()
RecentapplicationsList.reverse()
RecentapplicationsFile.close()
if RecentapplicationsList != []:
outfile = open (os.path.join(os.path.expanduser("~"), ListToAdd),mode)
outfile.write(ItemToAdd+"\n")
outfile.close()
else:
outfile = open (os.path.join(os.path.expanduser("~"), ListToAdd),mode)
outfile.write(ItemToAdd+"\n")
outfile.close()
def EditDesktopFile(DroppedFile,FileData,ListToAdd):
fileHandle = open ( DroppedFile , 'w' )
fileHandle.write ( '[Desktop Entry]\nEncoding=UTF-8\n' )
fileHandle.write ( 'Name='+FileData[0]+'\n')
fileHandle.write ( 'Comment='+FileData[1]+'\n')
fileHandle.write ( 'Exec='+FileData[2]+'\n')
fileHandle.write ( 'Icon='+FileData[3]+'\n')
fileHandle.write ( 'GenericName='+FileData[4]+'\n')
fileHandle.write ( 'Terminal='+FileData[5]+'\n')
fileHandle.close()
def WriteDesktopFile(DroppedFile,FileData,ListToAdd):
fileHandle = open ( DroppedFile , 'w' )
fileHandle.write ( '[Desktop Entry]\nEncoding=UTF-8\n' )
fileHandle.write ( 'Name='+FileData[0]+'\n')
fileHandle.write ( 'Comment='+FileData[1]+'\n')
fileHandle.write ( 'Exec='+FileData[2]+'\n')
fileHandle.write ( 'Icon='+FileData[3]+'\n')
fileHandle.write ( 'GenericName='+FileData[4]+'\n')
fileHandle.write ( 'Terminal='+FileData[5]+'\n')
fileHandle.close()
WriteListFile(ListToAdd,DroppedFile,"a")
print "Added to places.list"
"""
|