mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-30 08:53:05 +00:00
change , by ; in the csv file
This commit is contained in:
parent
9ddd6f0a73
commit
94bd846bc7
1 changed files with 8 additions and 8 deletions
16
lib/MPW.rb
16
lib/MPW.rb
|
@ -107,8 +107,8 @@ class MPW
|
||||||
file_pwd << passwd
|
file_pwd << passwd
|
||||||
file_pwd.close
|
file_pwd.close
|
||||||
end
|
end
|
||||||
rescue
|
rescue Exception => e
|
||||||
@error_msg = "Can't decrypt file!"
|
@error_msg = "Can't decrypt file!\n#{e}"
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class MPW
|
||||||
|
|
||||||
id = 0
|
id = 0
|
||||||
data_decrypt.lines do |line|
|
data_decrypt.lines do |line|
|
||||||
@data[id] = line.parse_csv.unshift(id)
|
@data[id] = line.parse_csv({:col_sep => ';'}).unshift(id)
|
||||||
id += 1;
|
id += 1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -158,7 +158,7 @@ class MPW
|
||||||
data_to_encrypt = ''
|
data_to_encrypt = ''
|
||||||
@data.each do |row|
|
@data.each do |row|
|
||||||
row.shift
|
row.shift
|
||||||
data_to_encrypt << "#{row.join(',')}\n"
|
data_to_encrypt << "#{row.join(';')}\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
crypto.encrypt(data_to_encrypt, :recipients => @key, :output => file_gpg)
|
crypto.encrypt(data_to_encrypt, :recipients => @key, :output => file_gpg)
|
||||||
|
@ -317,11 +317,11 @@ class MPW
|
||||||
begin
|
begin
|
||||||
data_new = IO.read(file)
|
data_new = IO.read(file)
|
||||||
data_new.lines do |line|
|
data_new.lines do |line|
|
||||||
if not line =~ /(.*,){6}/
|
if not line =~ /(.*;){6}/
|
||||||
@error_msg = "Can't import, the file is bad format!"
|
@error_msg = "Can't import, the file is bad format!"
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
row = line.parse_csv.unshift(0)
|
row = line.parse_csv({:col_sep => ';'}).unshift(0)
|
||||||
if not add(row[NAME], row[GROUP], row[SERVER], row[PROTOCOL], row[LOGIN], row[PASSWORD], row[PORT], row[COMMENT])
|
if not add(row[NAME], row[GROUP], row[SERVER], row[PROTOCOL], row[LOGIN], row[PASSWORD], row[PORT], row[COMMENT])
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -345,11 +345,11 @@ class MPW
|
||||||
|
|
||||||
data = IO.read(file)
|
data = IO.read(file)
|
||||||
data.lines do |line|
|
data.lines do |line|
|
||||||
if not line =~ /(.*,){6}/
|
if not line =~ /(.*;){6}/
|
||||||
@error_msg = "Can't import, the file is bad format!"
|
@error_msg = "Can't import, the file is bad format!"
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
result.push(line.parse_csv.unshift(id))
|
result.push(line.parse_csv({:col_sep => ';'}).unshift(id))
|
||||||
end
|
end
|
||||||
|
|
||||||
id += 1
|
id += 1
|
||||||
|
|
Loading…
Reference in a new issue