Escape character problem

View: New views
3 Messages — Rating Filter:   Alert me  

Escape character problem

by Saranakom Cheecharoen :: Rate this Message:

| View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Dear All,

 

I use cheetahtemplate to generate file path. Its code look like this:

---Test 1---

Temp_FileName = “${COMM_BUS}\\Pass through\\${eDME}_max.pkg”

t_FileName = Template(Temp_FileName,searchList = [dobj])

 

Output:

 

A_CAN\Pass through${eDME}_max.pkg

----End---

 

Why not they replace for ${eDME}? I think coz backslash is an escape character so cheetah ignore ${eDME} replacement.

Then I solve it by put more blackslash .

 

---Test2---

Temp_FileName = “${COMM_BUS}\\Pass through\\\${eDME}_max.pkg”

t_FileName = Template(Temp_FileName,searchList = [dobj])

 

Output:

 

A_CAN\Pass through\${eDME}_max.pkg

---End---

 

But it doesn’t work. Just got only backslash output not ${eDME} replacement.

 

---Test3---

Temp_FileName = “${COMM_BUS}\\Pass through\\_${eDME}_max.pkg”

t_FileName = Template(Temp_FileName,searchList = [dobj])

Output:

A_CAN\Pass through\_AgeDegHvsto_min.pkg

---End---

 

For Test3, just to prove that if I put underscore before ${eDME}, it work (replacement) but underscore is not what I want.

 

 

How I can solve this problem?

 

 

Best regard,

Saranakom Cheecharoen


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

Re: Escape character problem

by Jean-Baptiste Quenot-4 :: Rate this Message:

| View Threaded | Show Only this Message

This is a very creative way of using Cheetah, congratulations!

No, seriously, I would use Python's built-in dictionary-style string
formatting for this:

>>> "%(COMM_BUS)s\\Pass through\\%(eDME)s_max.pkg" % {'COMM_BUS': 'A_CAN', 'eDME': '123'}
'A_CAN\\Pass through\\123_max.pkg'
--
Jean-Baptiste Quenot

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

Re: Escape character problem

by Saranakom Cheecharoen :: Rate this Message:

| View Threaded | Show Only this Message

Thanks, Jean-Baptiste Quenot.

I have many things to learn more in Python.

Regards,
Long

-----Original Message-----
From: caraldi@... [mailto:caraldi@...] On Behalf Of
Jean-Baptiste Quenot
Sent: Monday, February 21, 2011 11:46 PM
To: Saranakom Cheecharoen
Cc: cheetahtemplate-discuss@...
Subject: Re: [Cheetahtemplate-discuss] Escape character problem

This is a very creative way of using Cheetah, congratulations!

No, seriously, I would use Python's built-in dictionary-style string
formatting for this:

>>> "%(COMM_BUS)s\\Pass through\\%(eDME)s_max.pkg" % {'COMM_BUS':
>>> 'A_CAN', 'eDME': '123'}
'A_CAN\\Pass through\\123_max.pkg'
--
Jean-Baptiste Quenot


------------------------------------------------------------------------------
Index, Search & Analyze Logs and other IT data in Real-Time with Splunk
Collect, index and harness all the fast moving IT data generated by your
applications, servers and devices whether physical, virtual or in the cloud.
Deliver compliance at lower cost and gain new business insights.
Free Software Download: http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Cheetahtemplate-discuss mailing list
Cheetahtemplate-discuss@...
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss